Important: The information in this document is obsolete and should not be used for new development.
CharWidth
TheCharWidth
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
TheCharWidth
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 ofSpaceExtra
. For a nonspace character,CharWidth
includes the effect ofCharExtra
. For more information, see "Individual Glyphs" on page 3-28.SPECIAL CONSIDERATIONS
Because it takes a single-byte value as thech
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 callTextWidth
.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 useTextWidth
.