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 3 - QuickDraw Text / QuickDraw Text Reference
Routines / Measuring Text


CharWidth

The CharWidth function returns the width in pixels of the specified character.

FUNCTION CharWidth (ch:\xDDCHAR): Integer;
ch
The character whose width is to be measured.
DESCRIPTION
The CharWidth function includes the effects of the stylistic variations for the text set in the current graphics port. If you change any of these attributes after determining the glyph width but before actually drawing it, the predetermined width may not be correct. For a space character, CharWidth also includes the effect of SpaceExtra. For a nonspace character, CharWidth includes the effect of CharExtra. For more information, see "Individual Glyphs" on page 3-28.

SPECIAL CONSIDERATIONS
Because it takes a single-byte value as the ch parameter, CharWidth works only for 1-byte simple script systems.

A series of calls to CharWidth in a contextual 1-byte font may give incorrect results, because the width of a text segment may be different from the sum of its individual character widths. In that case, to measure a line of text you should call TextWidth.

Do not use the CharWidth function for 2-byte script systems. If you want to measure the width of a single glyph in a 2-byte font, you should use TextWidth.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996