Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Text /
Chapter 4 - Font Manager / Font Manager Reference
Routines / Getting the Characteristics of a Font


FontMetrics

The FontMetrics procedure gets fractional measurements for the font, size, and style specified in the current graphics port.

PROCEDURE FontMetrics (VAR theMetrics: FMetricRec);
theMetrics
A font metrics record that contains the font measurement information, in fractional values.
DESCRIPTION
The FontMetrics procedure returns measurements for the ascent, descent, leading, and width of the largest glyph in the font for the font, size, and style specified in the current graphics port. FontMetrics returns this information in a font metrics record.

The font metrics record (of data type FMetricRec) contains a handle to the global width table, which in turn contains a handle to the associated font family resource for the current font (the font in the current graphics port). It also contains the values of four measurements for the current font.

Type FMetricRec =
RECORD
   ascent: Fixed;    {baseline to top}
   descent: Fixed;   {baseline to bottom}
   leading: Fixed;   {leading between lines}
   widMax: Fixed;    {maximum glyph width}
   wTabHandle: Handle; {handle to global width table}
END;
Field Description
ascent
The measurement from the baseline to the ascent line of the font.
descent
The measurement from the baseline to the descent line of the font.
leading
The measurement from the descent line to the ascent line below it.
widMax
The width of the largest glyph in the font.
wTabHandle
A handle to the global width table.
You can determine the line height, in pixels, by adding the values of the ascent, descent, and leading fields of the font metrics record.

The FontMetrics procedure is similar to QuickDraw's GetFontInfo procedure, except that FontMetrics returns fractional values for greater accuracy in high-resolution printing. FontMetrics also does not take into account any additional widths that are added by QuickDraw when it applies styles to the glyphs in a font.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro for the FontMetrics procedure is
Trap macro
_FontMetrics

SEE ALSO
The GetFontInfo procedure is described in the chapter "QuickDraw Text" in this book.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996