LOGFONT

Logical-Font Descriptor

The LOGFONT structure defines the attributes of a font, a drawing object used to write text on a display surface.

typedef struct tagLOGFONT {

short int lfHeight;

short int lfWidth;

short int lfEscapement;

short int lfOrientation;

short int lfWeight;

BYTE lfItalic;

BYTE lfUnderline;

BYTE lfStrikeOut;

BYTE lfCharSet;

BYTE lfOutPrecision;

BYTE lfClipPrecision;

BYTE lfQuality;

BYTE lfPitchAndFamily;

BYTE lfFaceName[LF_FACESIZE];

} LOGFONT;

The LOGFONT structure has the following fields:

Field Description  
lfHeight Specifies the average height of the font (in user units). The height of a font can be specified in the following three ways. If the lfHeight field is greater than zero, it is transformed into device units and matched against the cell height of the available fonts. If lfHeight is zero, a reasonable default size is used. If lfHeight is less than zero, it is transformed into device units and the absolute value is matched against the character height of the available fonts. To ensure compatibility with the font-scaling engine of future versions of Windows, lfHeight should be less than zero. Setting the high-order bit indicates that the font height does not take internal leading into consideration. This corresponds to the standard typographical EM height.  
lfWidth Specifies the average width of characters in the font (in device units). If the lfWidth field is zero, the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts for the closest match by absolute value of the difference.  
lfEscapement Specifies the angle (in tenths of degrees) between the escapement vector and the x-axis of the display surface. The escapement vector is the line through the origins of the first and last characters on a line. The angle is measured counterclockwise from the x-axis.  
lfOrientation Specifies the angle (in tenths of degrees) between the baseline of a character and the x-axis. The angle is measured counterclockwise from the x-axis.  
lfWeight Specifies the font weight (in inked pixels per 1000). Although the lfWeight field can be any integer value from 0 to 1000, the common values are as follows:  
  400 Normal 700 Bold  
  These values are approximate; the actual appearance depends on the font face. If lfWeight is zero, a default weight is used.  
lfItalic Specifies an italic font if set to nonzero.  
lfUnderline Specifies an underlined font if set to nonzero.  
lfStrikeOut Specifies a strikeout font if set to nonzero.  
lfCharSet Specifies the font's character set. The three values are predefined:  
  ANSI_CHARSET OEM_CHARSET SYMBOL_CHARSET  
  The OEM character set is system-dependent.  
  Fonts with other character sets may exist in the system. If an application uses a font with an unknown character set, it should not attempt to translate or interpret strings that are to be rendered with that font. Instead, the strings should be passed directly to the output device driver.  
lfOutPrecision Specifies the font's output precision, which defines how closely the output must match the requested font's height, width, character orientation, escapement, and pitch. The default setting is OUT_DEFAULT_PRECIS.  
lfClipPrecision Specifies the font's clipping precision, which defines how to clip characters that are partially outside the clipping region. The default setting is CLIP_DEFAULT_PRECIS.  
lfQuality Specifies the font's output quality, which defines how carefully GDI must attempt to match the logical-font attributes to those of an actual physical font. It can be any one of the following values:  
  Value Meaning
  DEFAULT_QUALITY Appearance of the font does not matter.
  DRAFT_QUALITY Appearance of the font is less important than when PROOF_QUALITY is used. For GDI fonts, scaling is enabled, which means that more font sizes are available, but the quality may be lower. Bold, italic, underline, and strikeout fonts are synthesized if necessary.
  Value Meaning
  PROOF_QUALITY Character quality of the font is more important than exact matching of the logical-font attributes. For GDI fonts, scaling is disabled and the font closest in size is chosen. Although the chosen font size may not be mapped exactly when PROOF_QUALITY is used, the quality of the font is high and there is no distortion of appearance. Bold, italic, underline, and strikeout fonts are synthesized if necessary.
lfPitchAndFamily Specifies the font pitch and family. The two low-order bits specify the pitch of the font and can be any one of the following values:  
  DEFAULT_PITCH FIXED_PITCH VARIABLE_PITCH  
  The four high-order bits of the field specify the font family and can be any one of the following values:  
  FF_DECORATIVE
FF_DONTCARE
FF_MODERN
FF_ROMAN
FF_SCRIPT
FF_SWISS
 
  The proper value can be obtained by using the Boolean OR operator to join one pitch constant with one family constant.  
  Font families describe the look of a font in a general way. They are intended for specifying fonts when the exact typeface desired is not available. The values for font families are as follows:  
  Value Meaning
  FF_DECORATIVE Novelty fonts. Old English, for example.
  FF_DONTCARE Don't care or don't know.
  FF_MODERN Fonts with constant stroke width (fixed-pitch), with or without serifs. Fixed-pitch fonts are usually modern. Pica, Elite, and Courier, for example.
  FF_ROMAN Fonts with variable stroke width (proportionally spaced) and with serifs. Times Roman, PalatinoÒ, and Century Schoolbook, for example.
  FF_SCRIPT Fonts designed to look like handwriting. Script and Cursive, for example.
  FF_SWISS Fonts with variable stroke width (proportionally spaced) and without serifs. HelveticaÒ and SwissÔ, for example.
lfFaceName Specifies the font's typeface. It must be a null-terminated character string. If lfFaceName is NULL, GDI uses a default typeface.  

See Also

The CreateFontIndirect function in Chapter 4, “Functions Directory.”