Carbon


WidthTable

Header: Fonts.h

struct WidthTable {
    Fixed tabData[256]; 
    Handle tabFont; 
    SInt32 sExtra; 
    SInt32 style; 
    SInt16 fID; 
    SInt16 fSize; 
    SInt16 face; 
    SInt16 device; 
    Point inNumer; 
    Point inDenom; 
    SInt16 aFID; 
    Handle fHand; 
    Boolean usedFam; 
    UInt8 aFace; 
    SInt16 vOutput; 
    SInt16 hOutput; 
    SInt16 vFactor; 
    SInt16 hFactor; 
    SInt16 aSize; 
    SInt16 tabSize;
};
typedef WidthTable WidthTablePtr;

Field descriptions

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.

tabSize

The total size of the global width table.

The global width table structure, 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 function 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 structure declaration; it may be larger because of some private system-specific information that is attached to it.

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 ‘NFNT'). 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 'sfnt'). 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 with the 'FOND' resource.
  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 ‘NFNT' 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 function MeasureText. The MeasureText function 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 function returns only the width of the largest glyph in a font contained in a bitmapped font resource.

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 function, see the documentation on “QuickDraw Text”. See also the FontMetrics and OutlineMetrics functions.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)