TGFont and TGFontPool
Encapsulate fonts used in the GUI system.
TGFontPool provides a pool of fonts.
TGTextLayout is used to keep track of string measurement
information when using the text layout facilities.
It can be displayed with respect to any origin.

Return the name of the corresponding Postscript font for this TGFont.
The return value is the pointsize of the TGFont. The name of the
Postscript font is appended to ds.
If the font does not exist on the printer, the print job will fail at
print time. Given a "reasonable" Postscript printer, the following
TGFont font families should print correctly:
Avant Garde, Arial, Bookman, Courier, Courier New, Geneva,
Helvetica, Monaco, New Century Schoolbook, New York,
Palatino, Symbol, Times, Times New Roman, Zapf Chancery,
and Zapf Dingbats.
Any other TGFont font families may not print correctly because the
computed Postscript font name may be incorrect.
dst -- Pointer to an initialized TString object to which the name of the
Postscript font that corresponds to the font will be appended.

Determine the number of characters from the string that will fit in the
given horizontal span. The measurement is done under the assumption that
DrawChars() will be used to actually display the characters.
The return value is the number of characters from source that fit into
the span that extends from 0 to maxLength. *length is filled with the
x-coordinate of the right edge of the last character that did fit.
source -- Characters to be displayed. Need not be '\0' terminated.
numChars -- Maximum number of characters to consider from source string.
maxLength -- If > 0, maxLength specifies the longest permissible line
length; don't consider any character that would cross this
x-position. If <= 0, then line length is unbounded and the
flags argument is ignored.
flags -- Various flag bits OR-ed together:
TEXT_PARTIAL_OK means include the last char which only
partially fit on this line.
TEXT_WHOLE_WORDS means stop on a word boundary, if possible.
TEXT_AT_LEAST_ONE means return at least one character even
if no characters fit.
*length -- Filled with x-location just after the terminating character.

A wrapper function for the more complicated interface of MeasureChars.
Computes how much space the given simple string needs.
The return value is the width (in pixels) of the given string.
string -- String whose width will be computed.
numChars -- Number of characters to consider from string, or < 0 for
strlen().

This procedure draws an underline for a given range of characters in a
given string. It doesn't draw the characters (which are assumed to have
been displayed previously); it just draws the underline. This procedure
would mainly be used to quickly underline a few characters without having
to construct an underlined font. To produce properly underlined text, the
appropriate underlined font should be constructed and used.
dst -- Window or pixmap in which to draw.
gc -- Graphics context for actually drawing line.
string -- String containing characters to be underlined or overstruck.
x, y -- Coordinates at which first character of string is drawn.
firstChar -- Index of first character.
lastChar -- Index of one after the last character.

Computes the amount of screen space needed to display a multi-line,
justified string of text. Records all the measurements that were done
to determine to size and positioning of the individual lines of text;
this information can be used by the TGTextLayout::DrawText() procedure
to display the text quickly (without remeasuring it).
This procedure is useful for simple widgets that want to display
single-font, multi-line text and want TGFont to handle the details.
The return value is a TGTextLayout token that holds the measurement
information for the given string. The token is only valid for the given
string. If the string is freed, the token is no longer valid and must
also be deleted.
The dimensions of the screen area needed to display the text are stored
in *width and *height.
string -- String whose dimensions are to be computed.
numChars -- Number of characters to consider from string, or < 0 for
strlen().
wrapLength -- Longest permissible line length, in pixels. <= 0 means no
automatic wrapping: just let lines get as long as needed.
justify -- How to justify lines.
flags -- Flag bits OR-ed together. kTextIgnoreTabs means that tab
characters should not be expanded. kTextIgnoreNewlines
means that newline characters should not cause a line break.
width -- Filled with width of string.
height -- Filled with height of string.

Helper function for ComputeTextLayout(). Encapsulates a measured set of
characters in a chunk that can be quickly drawn.
Returns a pointer to the new chunk in the text layout. The text layout is
reallocated to hold more chunks as necessary.
Currently, ComputeTextLayout() stores contiguous ranges of "normal"
characters in a chunk, along with individual tab and newline chars in
their own chunks. All characters in the text layout are accounted for.

Draw a string of characters on the screen. DrawCharsExp() expands
control characters that occur in the string to \X or \xXX sequences.
DrawChars() just draws the strings.
dst -- Window or pixmap in which to draw.
gc -- Graphics context for drawing characters.
source -- Characters to be displayed. Need not be'\0' terminated.
For DrawChars(), all meta-characters (tabs, control
characters, and newlines) should be stripped out of the
string that is passed to this function. If they are not
stripped out, they will be displayed as regular printing
characters.
numChars -- Number of characters in string.
x, y -- Coordinates at which to place origin of string when drawing.