LOGFONT

2.x

typedef struct tagLOGFONT {     /* lf */
    int   lfHeight;
    int   lfWidth;
    int   lfEscapement;
    int   lfOrientation;
    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 defines the attributes of a font, a drawing object used to write text on a display surface.

Members

lfHeight

Specifies the desired height, in logical units, for the font. If this value is greater than zero, it specifies the cell height of the font. If it is less than zero, it specifies the character height of the font. (Character height is the cell height minus the internal leading. Applications that specify font height in points typically use a negative number for this member.) If this value is zero, the font mapper uses a default height. The font mapper chooses the largest physical font that does not exceed the requested size (or the smallest font, if all the fonts exceed the requested size). The absolute value of the lfHeight member must not exceed 16,384 after it is converted to device units.

lfWidth

Specifies the average width, in logical units, of characters in the font. If this value is zero, the font mapper chooses a reasonable default width for the specified font height. (The default width is chosen by matching the aspect ratio of the device against the digitization aspect ratio of the available fonts. The closest match is determined by the absolute value of the difference.) The widths of characters in TrueType fonts are scaled by a factor of this member divided by the width of the characters in the physical font (as specified by the tmAveCharWidth member of the TEXTMETRIC structure).

lfEscapement

Specifies the angle, in tenths of degrees, between the base line of a character and the x-axis. The angle is measured in a counterclockwise direction from the x-axis for left-handed coordinate systems (that is, MM_TEXT, in which the y direction is down) and in a clockwise direction from the x-axis for right-handed coordinate systems (in which the y direction is up).

lfOrientation

Specifies the orientation of the characters. This value is ignored.

lfWeight

Specifies the font weight. This member can be one of the following values:

Constant Value

FW_DONTCARE 0
FW_THIN 100
FW_EXTRALIGHT 200
FW_ULTRALIGHT 200
FW_LIGHT 300
FW_NORMAL 400
FW_REGULAR 400
FW_MEDIUM 500
FW_SEMIBOLD 600
FW_DEMIBOLD 600
FW_BOLD 700
FW_EXTRABOLD 800
FW_ULTRABOLD 800
FW_BLACK 900
FW_HEAVY 900

The actual appearance of the font depends on the type face. Some fonts have only FW_NORMAL, FW_REGULAR, and FW_BOLD weights. If FW_DONTCARE is specified, a default weight is used.

lfItalic

Specifies an italic font if nonzero.

lfUnderline

Specifies an underlined font if nonzero.

lfStrikeOut

Specifies a strikeout font if nonzero.

lfCharSet

Specifies the character set of the font. The following values are predefined:

Constant Value

ANSI_CHARSET 0
DEFAULT_CHARSET 1
SYMBOL_CHARSET 2
SHIFTJIS_CHARSET 128
OEM_CHARSET 255

The DEFAULT_CHARSET value is not used by the font mapper. An application can use this value to allow the name and size of a font to fully describe the logical font. If the specified font name does not exist, a font from any character set can be substituted for the specified font; applications should use the DEFAULT_CHARSET value sparingly to avoid unexpected results.

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 height, width, character orientation, escapement, and pitch of the requested font. This member can be one of the following values:

OUT_CHARACTER_PRECIS OUT_DEFAULT_PRECIS OUT_DEVICE_PRECIS OUT_RASTER_PRECIS OUT_STRING_PRECIS OUT_STROKE_PRECIS OUT_TT_PRECIS OUT_TT_ONLY_PRECIS

Applications can use the values OUT_DEVICE_PRECIS, OUT_RASTER_PRECIS, and OUT_TT_PRECIS to control how the font mapper chooses a font when the system contains more than one font with a given name. For example, if a system contains a font named “Symbol” in raster and TrueType form, specifying OUT_TT_PRECIS would force the font mapper to choose the TrueType version. (Specifying OUT_TT_PRECIS forces the font mapper to choose a TrueType font whenever the specified font name matches a device or raster font, even when there is no TrueType font with the same name.)

An application can use TrueType fonts exclusively by specifying OUT_TT_ONLY_PRECIS. When this value is specified, the system chooses a TrueType font even when the name specified in the lfFaceName member matches a raster or vector font.

lfClipPrecision

Specifies the desired clipping precision. The clipping precision defines how to clip characters that are partially outside the clipping region. This member can be any one of the following values:

CLIP_CHARACTER_PRECIS CLIP_DEFAULT_PRECIS CLIP_EMBEDDED CLIP_LH_ANGLES CLIP_MASK CLIP_STROKE_PRECIS CLIP_TT_ALWAYS

To use an embedded read-only font, applications must specify the CLIP_EMBEDDED value.

To achieve consistent rotation of device, TrueType, and vector fonts, an application can use the OR operator to combine the CLIP_LH_ANGLES value with any of the other lfClipPrecision values. If the CLIP_LH_ANGLES bit is set, the rotation for all fonts is dependent on whether the orientation of the coordinate system is left-handed or right-handed. If CLIP_LH_ANGLES is not set, device fonts always rotate counter-clockwise, but the rotation of other fonts is dependent on the orientation of the coordinate system. (For more information about the orientation of coordinate systems, see the description of the lfEscapement member.)

lfQuality

Specifies the output quality of the font, which defines how carefully the graphics device interface (GDI) must attempt to match the logical-font attributes to those of an actual physical font. This member can be 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 the PROOF_QUALITY value is used. For GDI raster fonts, scaling is enabled. 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 raster fonts, scaling is disabled and the font closest in size is chosen. Bold, italic, underline, and strikeout fonts are synthesized if necessary.

lfPitchAndFamily

Specifies the pitch and family of the font. The two low-order bits, which specify the pitch of the font, can be one of the following values:

DEFAULT_PITCH FIXED_PITCH VARIABLE_PITCH

The four high-order bits of the member, which specify the font family, can be one of the following values:

Value Meaning

FF_DECORATIVE Novelty fonts. Old English is an example.
FF_DONTCARE Don't care or don't know.
FF_MODERN Fonts with constant stroke width, with or without serifs. Pica, Elite, and Courier NewŇ are examples.
FF_ROMAN Fonts with variable stroke width and with serifs. Times New RomanŇ and New Century SchoolbookŇ are examples.
FF_SCRIPT Fonts designed to look like handwriting. Script and Cursive are examples.
FF_SWISS Fonts with variable stroke width and without serifs. MSŇ Sans Serif is an example.

An application can specify a value for the lfPitchAndFamily member by using the Boolean OR operator to join a pitch constant with a 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.

lfFaceName

Specifies the typeface name of the font. The length of this string must not exceed LF_FACESIZE – 1. The EnumFontFamilies function can be used to enumerate the typeface names of all currently available fonts. If lfFaceName is NULL, GDI uses a device-dependent typeface.

Comments

Applications can use the default settings for most of these members when creating a logical font. The members that should always be given specific values are lfHeight and lfFaceName. If lfHeight and lfFaceName are not set by the application, the logical font that is created is device-dependent.

See Also

CreateFontIndirect, EnumFontFamilies