The TEXTMETRIC structure contains basic information about a physical font. All sizes are given in logical units; that is, they depend on the current mapping mode of the display context.
typedef struct tagTEXTMETRIC { // tm LONG tmHeight; LONG tmAscent; LONG tmDescent; LONG tmInternalLeading; LONG tmExternalLeading; LONG tmAveCharWidth; LONG tmMaxCharWidth; LONG tmWeight; LONG tmOverhang; LONG tmDigitizedAspectX; LONG tmDigitizedAspectY; BCHAR tmFirstChar; BCHAR tmLastChar; BCHAR tmDefaultChar; BCHAR tmBreakChar; BYTE tmItalic; BYTE tmUnderlined; BYTE tmStruckOut; BYTE tmPitchAndFamily; BYTE tmCharSet; } TEXTMETRIC;
The tmOverhang member enables the application to determine how much of
the character width returned by a GetTextExtentPoint32
function call on a single character is the actual character width and how much
is the per-string extra width. The actual width is the extent minus the
overhang.
The four low-order bits of this member specify information about the pitch and the technology of the font. A constant is defined for each of the four bits:
Constant |
Meaning |
TMPF_FIXED_PITCH |
If this bit is set the font is a variable pitch font. If this bit is clear the font is a fixed pitch font. Note very carefully that those meanings are the opposite of what the constant name implies. |
TMPF_VECTOR |
If this bit is set the font is a vector font. |
TMPF_TRUETYPE |
If this bit is set the font is a TrueType font. |
TMPF_DEVICE |
If this bit is set the font is a device font. |
An application should carefully test for qualities encoded in these low-order bits, making no arbitrary assumptions. For example, besides having their own bits set, TrueType and PostScript fonts set the TMPF_VECTOR bit. A monospace bitmap font has all of these low-order bits clear; a proportional bitmap font sets the TMPF_FIXED_PITCH bit. A Postscript printer device font sets the TMPF_DEVICE, TMPF_VECTOR, and TMPF_FIXED_PITCH bits.
The four high-order bits of tmPitchAndFamily designate the font’s font
family. An application can use the value 0xF0 and the bitwise AND operator to
mask out the four low-order bits of tmPitchAndFamily, thus obtaining a
value that can be directly compared with font family names to find an
identical match. For information about font families, see the description of
the LOGFONT structure.