Example: Manual Underlining

The easiest way to underline characters is to use the special underlining sequences recognized by fgf_print() and fgf_printc(). Suppose, however, that we instead want to perform the underlining manually, perhaps to draw a thicker underline. We'll do this by drawing a line just beneath the characters, but how do we compute the position of this line? Determining the line length is easy -- it's the same as the width of the string being underlined. We want the vertical position of the line to be two pixels below the characters, except for descender characters (which will extend below the underline).

The height of a string includes the space reserved for descender characters. This means if we used only the string height as the basis for drawing the underline, it would appear below the tips of the descenders. Fortunately, Fastgraph/Fonts provides an easy solution. The function fgf_drop() returns as its function value the number of pixel rows descender characters extend below the other characters. Hence, the vertical coordinate for the underline is the height of the string, less the value of fgf_drop(), plus two pixel rows (the two pixel rows provide one blank row between the characters and the underline). Example FGFW6 demonstrates this process.

C/C++ version

C++Builder version

Delphi version

Visual Basic version

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.