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
Data Structures


The Global Width Table

The global width table record, of data type WidthTable, contains the widths of all the glyphs of one font. The font family, point size, and style of this font are specified in this table. Your application should use the widths found in the global width table for placement of glyphs and words both on the screen and on the printed page. You can use the FontMetrics procedure, described on page 4-50, to get a handle to the global width table. However, you should not assume that the table is the same size as shown in the record declaration; it may be larger because of some private system-specific information that is attached to it.

Type WidthTable =
PACKED RECORD
   tabData: ARRAY [1..256] OF Fixed;
                           {character widths}
   tabFont:    Handle;     {font record used to build table}
   sExtra:     LongInt;    {extra line spacing}
   style:      LongInt;    {extra line spacing due to style}
   fID:        Integer;    {font family ID}
   fSize:      Integer;    {font size request}
   face:       Integer;    {style (face) request}
   device:     Integer;    {device requested}
   inNumer:    Point;      {scale factors requested}
   inDenom:    Point;      {scale factors requested}
   aFID:       Integer;    {actual font family ID for table}
   fHand:      Handle;     {family record used to build up table}
   usedFam:    Boolean;    {used fixed-point family widths}
   aFace:      Byte;       {actual face produced}
   vOutput:    Integer;    {vertical scale output value}
   hOutput:    Integer;    {horizontal scale output value}
   vFactor:    Integer;    {vertical scale output value}
   hFactor:    Integer;    {horizontal scale output value}
   aSize:      Integer;    {size of actual font used}
   tabSize:    Integer;    {total size of table}
END;
Field Description
tabData
The widths for the glyphs in the font, in standard 32-bit fixed-point format. If a glyph is missing in the font, its entry contains the width of the missing-character glyph.
tabFont
A handle to the font resource used to build this table.
sExtra
The average number of pixels by which QuickDraw widens each space in a line of text.
style
The average number of pixels by which QuickDraw widens a line of text after applying a style.
fID
The font family ID of the font represented by this table. This is the ID that was used in the request to build the table. It may be different from the ID of the font family that was used, which is indicated by the aFID field.
fSize
The point size that was originally requested for the font represented by this table. The actual size used is specified in the aSize field.
face
The font style that was originally requested for the font represented by this table. The actual style used is specified in the aFace field.
device
The device ID of the device on which these widths may be used.
inNumer
The numerators of the vertical and horizontal scaling factors. The numer field is of type Point and contains two integers: the first is the numerator of the ratio for vertical scaling and the second is the numerator of the ratio for horizontal scaling.
inDenom
The denominators of the vertical and horizontal scaling factors. The denom field is of type Point and contains two integers: the first is the denominator of the ratio for vertical scaling and the second is the denominator of the ratio for horizontal scaling.
aFID
The font family ID of the font family actually used to build this table. If the Font Manager could not find the font requested, this value may be different from the value of the fID field.
fHand
The handle to the font family resource used to build this table.
usedFam
Set to TRUE if the fixed-point family glyph widths were used rather than integer glyph widths.
aFace
The font style of the font whose widths are contained in this table.
vOutput
The factor by which glyphs are to be expanded vertically in the current graphics port. This is a 16-bit fixed-point number, with the integer part in the high-order byte and a fractional part in the low-order byte.
hOutput
The factor by which glyphs are to be expanded horizontally in the current graphics port. This is a 16-bit fixed-point number, with the integer part in the high-order byte and a fractional part in the low-order byte.
vFactor
The factor by which widths of the chosen font, after a style has been applied, have been increased vertically in the current graphics port. This is a 16-bit fixed-point number, with the integer part in the high-order byte and a fractional part in the low-order byte. The value of the vFactor field is not used by the Font Manager.
hFactor
The factor by which widths of the chosen font, after a style has been applied, have been increased horizontally in the current graphics port. This is a 16-bit fixed-point number, with the integer part in the high-order byte and a fractional part in the low-order byte.
aSize
The size of the font actually used to build this table. Both the point size and the font used to build this table may be different from the requested point size and font. If font scaling is disabled, the Font Manager may use a size different from the size requested and add more or less space to approximate the appearance of the font requested. See "The Scaling Process for a Bitmapped Font" on page 4-21 for more information.
tabSize
The total size of the global width table.
Multiplying the values of the hOutput and vOutput fields by the values of the hFactor and vFactor fields, respectively, gives the font scaling. (Because the value of the vFactor field is ignored, the Font Manager multiplies the value of the vOutput field by 1.) The product of the value of the hOutput field and an entry in the global width table is the scaled width for that glyph.

The Font Manager gathers data for the global width table from one of three data structures:

  1. The Font Manager looks in the font resource for a table that stores fractional glyph widths. For bitmapped fonts, the Font Manager uses the glyph-width table of the bitmapped font resource (described on page 4-66). For outline fonts, the Font Manager uses the advance width and left-side bearing values in the horizontal metrics table of the outline font (described on page 4-78). In both cases, the values are stored in 16-bit fixed format, with the integer part in the high-order byte and the fractional part in the low-order byte.
  2. If there is no glyph-width table in the font resource, the Font Manager looks for the font family's glyph-width table in the font family resource, which contains fractional widths for a hypothetical 1-point font. The Font Manager calculates the actual values by multiplying these widths by the requested font size. The font family's glyph-width table is described in "The Family Glyph-Width Table" on page 4-92.
  3. If there is no glyph-width table in the font family resource, and if the font is contained in a bitmapped font resource, the Font Manager derives the glyph widths from the integer widths contained in the glyph-width table of the bitmapped font resource, which is described on page 4-66. There is no corresponding table for the outline font resource.

Your application should obtain glyph widths either from the global width table or from the QuickDraw procedure MeasureText. The MeasureText procedure works only with text to be displayed on the screen, not with text to be printed. You can get the individual widths of glyphs of an outline font using the OutlineMetrics function. The FontMetrics procedure returns only the width of the largest glyph in a font contained in a bitmapped font resource.

IMPORTANT
Do not use the values from the global width table if your application is running on a computer on which non-Roman script systems are installed. You can check to see if a non-Roman script system is present by calling the GetScriptManagerVariable function with a selector of smEnabled; if the function returns a value greater than 0, at least one non-Roman script system is present and you need to call MeasureText to measure text that is displayed on the screen. Measuring text from a non-Roman script system for printing is handled by the printer driver.
For more information about the MeasureText procedure, see the chapter "QuickDraw Text" in this book. The FontMetrics procedure is described on page 4-50 and the OutlineMetrics function is described on page 4-52.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996