typedef struct tagLOGFONT { /* lf */
LONG lfHeight;
LONG lfWidth;
LONG lfEscapement;
LONG lfOrientation;
LONG 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 defines the attributes of a font, a drawing object used to write text on a display surface.
lfHeight
Specifies the desired height (in logical units) of the font. The font height can be specified in three ways: If lfHeight is greater than zero, it is transformed into device units and matched against the cell height of the available fonts. If it is zero, a reasonable default size is used. If it is less than zero, it is transformed into device units and the absolute value is matched against the character height of the available fonts. For all height comparisons, the font mapper looks for the largest font that does not exceed the requested size, and, if there is no such font, looks for the smallest font available. This mapping will occur when the font is actually used for the first time.
lfWidth
Specifies the average width (in logical units) of characters in the font. If lfWidth is zero, the aspect ratio of the device will be matched against the digitization aspect ratio of the available fonts to find the closest match, determined by the absolute value of the difference.
lfEscapement
Specifies the angle (in tenths of degrees) of each line of text written in the font (relative to the bottom of the page).
lfOrientation
Specifies the angle (in tenths of degrees) of each character's baseline (relative to the bottom of the page).
lfWeight
Specifies the desired weight of the font in the range 0 to 1000 (for example, 400 is normal, 700 is bold). If lfWeight is zero, a default weight is used.
lfItalic
TRUE if the desired font is Italic.
lfUnderline
TRUE if text drawn with this font will be underlined.
lfStrikeOut
TRUE if text drawn with this font will be struck out.
lfCharSet
Specifies the desired character set. The following values are predefined:
ANSI_CHARSET OEM_CHARSET SYMBOL_CHARSET UNICODE_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.
lfOutPrecision
Specifies the desired output precision. The output precision defines how closely the output must match the requested font's height, width, character orientation, escapement, and pitch. It can be any one of the following values:
OUT_CHARACTER_PRECIS OUT_DEFAULT_PRECIS OUT_STRING_PRECIS OUT_STROKE_PRECIS
lfClipPrecision
Specifies the desired clipping precision. The clipping precision defines how to clip characters that are partially outside the clipping region. It can be any one of the following values:
CLIP_CHARACTER_PRECIS CLIP_DEFAULT_PRECIS CLIP_STROKE_PRECIS
lfQuality
Specifies the desired output quality. The output quality 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. |
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 pitch and family of the font. 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
Bits 4 through 7 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(TM), for example. |
lfFaceName
Points to a null-terminated character string that specifies the typeface name of the font. The length of this string must not exceed 32 characters. The EnumFonts function can be used to enumerate the typeface names of all currently available fonts. If lfFaceName is NULL, GDI uses a default typeface.
CreateFontIndirect