LOGFONT

This structure defines the properties of the text style.

struct LOGFONT {
	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;
	TCHAR lfFaceName[LF_FACESIZE];
};

Members

lfHeight

The height of the text.

lfWidth

The average width of the character. If 0, the scale is adaptive.

lfEscapement

The writing angle of the string, 0.1 degrees, defaults to 0.

lfOrientation

The writing angle of each character, 0.1 degrees, defaults to 0.

lfWeight

The stroke weight of the character, the range of 01000, 0 indicates the default weight, using numbers or macros defined in the table below.

Value Description
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_HEAVY 900
FW_BLACK 900

lfItalic

Specify whether the font is italic.

lfUnderline

Specify whether the font is underlined.

lfStrikeOut

Specify whether the font has a strikeout.

lfCharSet

Specifies the character set. You can use the following predefined values:

  • ANSI_CHARSET
  • BALTIC_CHARSET
  • CHINESEBIG5_CHARSET
  • DEFAULT_CHARSET (The character set is based on the local operating system. For example, the system location is English ( United States) and the character set will be set to ANSI-CHARSET)
  • EASTEUROPE_CHARSET
  • GB2312_CHARSET
  • GREEK_CHARSET
  • HANGUL_CHARSET
  • MAC_CHARSET
  • OEM_CHARSET (Character sets depend on the local operating system)
  • RUSSIAN_CHARSET
  • SHIFTJIS_CHARSET
  • SYMBOL_CHARSET
  • TURKISH_CHARSET

lfOutPrecision

Specifies the output accuracy of the text. Output precision defines the extent to which the output must match the requested font height, width, character direction, leading, spacing, and font type. This can be the following value:

Value Description
OUT_DEFAULT_PRECIS Specify the default mapping behavior.
OUT_DEVICE_PRECIS When the system contains multiple fonts with the same name, specify the device font.
OUT_OUTLINE_PRECIS Specify the font map to select TrueType and other outline-based fonts.
OUT_RASTER_PRECIS When the system contains more than one font with the same name, specify a raster font (that is, a dot matrix font).
OUT_STRING_PRECIS This value is not used to specify a font map, but simply to specify the dot matrix font enumeration data.
OUT_STROKE_PRECIS This value is not used to specify a font map, but simply to trueType and other outline-type fonts, as well as enumerated data for vector fonts.
OUT_TT_ONLY_PRECIS The specified font map selects only TrueType fonts. If the TrueType font is not installed on the system, the default action is selected.
OUT_TT_PRECIS When the system contains multiple fonts with the same name, specify the TrueType font.

lfClipPrecision

Specifies the clip accuracy of the text. Clip precision defines how a portion of a clip character is located outside the clip area. This can be the following value:

Value Description
CLIP_DEFAULT_PRECIS Specify the default clip behavior.
CLIP_STROKE_PRECIS This value cannot be used to specify font mapping, but to specify enumeration data for gratings (dot matrix), vectors, or TrueType fonts.
CLIP_EMBEDDED This flag must be specified when using inline read-only fonts.
CLIP_LH_ANGLES If this value is specified, the rotation of all fonts depends on the direction of the coordinate system being counterclockwise or clockwise.
If this value is not specified, the device font always rotates counterclockwise, but the rotation of other fonts depends on the direction of the coordinate system.
This setting affects the effect of the lfOrientation parameter.

lfQuality

Specifies the output quality of the text. Output quality defines how carefully the graphical device interface (GDI) must attempt to match the logical font properties to the font properties of the actual physical font. This can be the following value:

Value Description
ANTIALIASED_QUALITY Specifies that the output quality is anti-aliased ( if the font supports it).
DEFAULT_QUALITY The specified output quality is not important.
DRAFT_QUALITY Draft quality. The quality of the font display is not important. For grating fonts (dot matrix fonts), scaling is effective, which means that more dimensions can be used, but the display quality is not high. Bold, italic, underscore, and strikeout fonts are synthesized if required.
NONANTIALIASED_QUALITY The specified output quality is not anti-aliasing.
PROOF_QUALITY The quality of the draft. Specifying font quality is more important than matching font properties. For grating fonts (dot matrix fonts), scaling is not valid and the nearest font size is selected. Although the font size cannot be accurately mapped when PROOF-QUALITY is selected, the output quality is high and there is no distortion. Bold, italic, underscore, and strikeout fonts are synthesized if required.

If neither ANTIALIASED-QUALITY and NONANTIALIASED-QUALITY are selected, the anti-aliasing effect will depend on the anti-aliasing settings of the font in the control panel.

lfPitchAndFamily

Specifies a font family that describes a font in a general way. The font family describes the approximate font appearance. A font family is used to specify a font when the exact font you want is not available. 1 to 2 bits specify the font spacing, which can be the following values:

Value Description
DEFAULT_PITCH Specify the default spacing.
FIXED_PITCH Specify a fixed spacing.
VARIABLE_PITCH Specify variable spacing.

4~7 bit specified font family, which can be the following values:

Value Description
FF_DECORATIVE Specifies a special font. For example, Old English.
FF_DONTCARE The specified font family is not important.
FF_MODERN Specifies an isometric font with or without serifs. For example, Pica, Elite, and Courier New are all equal-width fonts.
FF_ROMAN Specifies an equidistant font with serifs. For example, MS Serif.
FF_SCRIPT Specifies a font designed to be similar to handwriting. For example, Script and Cursive.
FF_SWISS Specifies an equidistant font that does not have serifs. For example, MS Sans Serif.

Font spacing and font families can be connected with the Boolean operator OR (the symbol | ).

lfFaceName

The font name must not exceed 31 characters. If it is an empty string, the system uses the first font that meets other properties.

(贡献者:Krissi  编辑