TEXTMETRIC

Basic Font Metrics

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 {

short int tmHeight;

short int tmAscent;

short int tmDescent;

short int tmInternalLeading;

short int tmExternalLeading;

short int tmAveCharWidth;

short int tmMaxCharWidth;

short int tmWeight;

BYTE tmItalic;

BYTE tmUnderlined;

BYTE tmStruckOut;

BYTE tmFirstChar;

BYTE tmLastChar;

BYTE tmDefaultChar;

BYTE tmBreakChar;

BYTE tmPitchAndFamily;

BYTE tmCharSet;

short int tmOverhang;

short int tmDigitizedAspectX;

short int tmDigitizedAspectY;

} TEXTMETRIC;

The TEXTMETRIC structure has the following fields:

Field Description  
tmHeight Specifies the height (ascent + descent) of characters.  
tmAscent Specifies the ascent (units above the baseline) of characters.  
tmDescent Specifies the descent (units below the baseline) of characters.  
tmInternalLeading Specifies the amount of leading (space) inside the bounds set by the tmHeight field. Accent marks and other foreign characters may occur in this area. The designer may set this field to zero.  
tmExternalLeading Specifies the amount of extra leading (space) that the application adds between rows. Since this area is outside the font, it contains no marks and will not be altered by text output calls in either OPAQUE or TRANSPARENT mode. The designer may set this field to zero.  
tmAveCharWidth Specifies the average width of characters in the font (loosely defined as the width of the letter x). This value does not include overhang required for bold or italic characters.  
tmMaxCharWidth Specifies the width of the widest character in the font.  
tmWeight Specifies the weight of the font.  
tmItalic Specifies an italic font if it is nonzero.  
tmUnderlined Specifies an underlined font if it is nonzero.  
tmStruckOut Specifies a struckout font if it is nonzero.  
tmFirstChar Specifies the value of the first character defined in the font.  
tmLastChar Specifies the value of the last character defined in the font.  
tmDefaultChar Specifies the value of the character that will be substituted for characters that are not in the font.  
tmBreakChar Specifies the value of the character that will be used to define word breaks for text justification.  
tmPitchAndFamily Specifies the pitch and family of the selected font. The low-order bit specifies the pitch of the font. If it is 1, the font is variable pitch. If it is 0, the font is fixed pitch.  
  The four high-order bits designate the font family. The tmPitchAndFamily field can be combined with the hexadecimal value 0xF0 by using the bitwise AND operator, and then be compared with the font family names for an identical match. For a description of the font families, see the LOGFONT structure, earlier in this chapter.  
tmCharSet Specifies the character set of the font.  
tmOverhang Specifies the per-string extra width that may be added to some synthesized fonts. When synthesizing some attributes, such as bold or italic, GDI or a device may have to add width to a string on both a per-character and per-string basis. For example, GDI makes a string bold by expanding the intracharacter spacing and overstriking by an offset value; it italicizes a font by skewing the string. In either case, there is an overhang past the basic string. For bold strings, the overhang is the distance by which the overstrike is offset. For italic strings, the overhang is the amount the top of the font is skewed past the bottom of the font.  
  The tmOverhang field allows the application to determine how much of the character width returned by a GetTextExtent 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.  
tmDigitizedAspectX Specifies the horizontal aspect of the device for which the font was designed.  
tmDigitizedAspectY Specifies the vertical aspect of the device for which the font was designed. The ratio of the tmDigitizedAspectX and tmDigitizedAspectY fields is the aspect ratio of the device for which the font was designed.  

See Also

The GetDeviceCaps and GetTextMetrics functions in Chapter 4, “Functions Directory.”