LOGFONT

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This structure defines the attributes of a font.

Syntax

typedef struct tagLOGFONT { 
  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]; 
} LOGFONT; 

Members

  • lfHeight
    Specifies the height, in logical units, of the font's character cell or character. The character height value (also known as the em height) is the character cell height value minus the internal-leading value. The font mapper interprets the value specified in lfHeight in the following manner.

    Value Description

    > 0

    The font mapper transforms this value into device units and matches it against the cell height of the available fonts.

    0

    The font mapper uses a default height value when it searches for a match.

    < 0

    The font mapper transforms this value into device units and matches its absolute value 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.

    This mapping occurs when the font is used for the first time.

    For the MM_TEXT mapping mode, you may use the following formula to specify a height for a font with a given point size.

    lfHeight = -MulDiv(pointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
    

    where MulDiv is defined as follows:

    #define MulDiv(a,b,c)       (((a)*(b))/(c))
    

    Here the GetDeviceCaps function returns the number of pixels per logical inch along the screen height.

    Note

    Some character sets such as Meiryo have a large internal leading height. Because of this it is usually best to specify lfHeight as a negative value as in the example above. When an application specifies a negative value, the font mapper provides the closest match for the character height rather than the cell height. Thus if a character set such as Meiryo has a large internal leading height, the font mapper will still provide a font that fits the total character height specified (the absolute value of lfHeight). Use of the Meiryo font should be thoroughly tested.

  • lfWidth
    Specifies the average width, in logical units, of characters in the font. If lfWidth is not zero, the aspect ratio of the device is 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, between the escapement vector and the x-axis of the device. The escapement vector is parallel to the base line of a row of text.

    The lfEscapement member specifies both the escapement and orientation. You should set lfEscapement and lfOrientation to the same value.

  • lfOrientation
    Specifies the angle, in tenths of degrees, between each character's base line and the x-axis of the device.
  • lfWeight
    Specifies the weight of the font in the range 0 through 1000. For example, 400 is normal and 700 is bold. If this value is zero, a default weight is used.

    The following values are defined for convenience.

    Value Weight

    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
    Specifies an italic font if set to TRUE.
  • lfUnderline
    Specifies an underlined font if set to TRUE.
  • lfStrikeOut
    Specifies a strikeout font if set to TRUE.
  • lfCharSet
    Specifies the character set. The following values are predefined:

    ANSI_CHARSET

    BALTIC_CHARSET

    CHINESEBIG5_CHARSET

    DEFAULT_CHARSET

    EASTEUROPE_CHARSET

    GB2312_CHARSET

    GREEK_CHARSET

    HANGUL_CHARSET

    MAC_CHARSET

    OEM_CHARSET

    RUSSIAN_CHARSET

    SHIFTJIS_CHARSET

    SYMBOL_CHARSET

    TURKISH_CHARSET

    Korean Windows

    JOHAB_CHARSET

    Middle-Eastern Windows

    HEBREW_CHARSET

    ARABIC_CHARSET

    Thai Windows

    THAI_CHARSET

    The OEM_CHARSET value specifies a character set that is operating-system dependent.

    DEFAULT_CHARSET is set to a value based on the current system locale. For example, when the system locale is English (United States), the value is ANSI_CHARSET.

    Fonts with other character sets may exist in the operating system. If an application uses a font with an unknown character set, it should not attempt to translate or interpret strings that are rendered with that font.

    This member is important in the font mapping process. To ensure consistent results, specify a specific character set. If you specify a typeface name in the lfFaceName member, make sure that the lfCharSet value matches the character set of the typeface specified in lfFaceName.

  • lfOutPrecision
    Specifies the output precision. The output precision defines how closely the output must match the requested font's height, width, character orientation, escapement, pitch, and font type. It can be one of the following values.

    Value Description

    OUT_DEFAULT_PRECIS

    Specifies the default font mapper behavior.

    OUT_RASTER_PRECIS

    Instructs the font mapper to choose a raster font when the system contains multiple fonts with the same name.

    OUT_STRING_PRECIS

    This value is not used by the font mapper, but it is returned when raster fonts are enumerated.

  • lfClipPrecision
    Specifies the clipping precision. The clipping precision defines how to clip characters that are partially outside the clipping region. It can be one or more of the following values.

    Value Description

    CLIP_DEFAULT_PRECIS

    Specifies default clipping behavior.

    CLIP_CHARACTER_PRECIS

    Not used.

    CLIP_STROKE_PRECIS

    Not used by the font mapper, but is returned when raster, vector, or TrueType fonts are enumerated.

  • lfQuality
    Specifies the output quality. The output quality defines how carefully the graphics device interface (GDI) must attempt to match the logical-font attributes to those of an actual physical font. It can be one of the following values.

    Value Description

    ANTIALIASED_QUALITY

    Enables antialiasing for the font. The display driver must support antialiased text for this setting to work.

    NONANTIALIASED_QUALITY

    Forces use of draft quality when the HKEY_LOCAL_MACHINE\System\GDI\Fontsmoothing registry key is present.

    CLEARTYPE_COMPAT_QUALITY

    Enables ClearType® text for the font using compatible widths. A compatible width produces text that has the same spacing as non-ClearType text.

    CLEARTYPE_QUALITY

    Enables ClearType text for the font. The display driver must support ClearType text for this setting to work.

    DEFAULT_QUALITY

    Appearance of the font does not matter.

    DRAFT_QUALITY

    For GDI raster 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.

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

    • DEFAULT_PITCH
    • FIXED_PITCH
    • VARIABLE_PITCH

    Bits 4 through 7 of the member specify the font family and can be 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 Description

    FF_DECORATIVE

    Novelty fonts, for example, Old English.

    FF_DONTCARE

    Do not care or do not know.

    FF_MODERN

    Fonts with constant stroke width (monospace), with or without serifs. Monospace fonts are usually modern, for example, Pica, Elite, and Courier New.

    FF_ROMAN

    Fonts with variable stroke width (proportional) and with serifs, for example, Serif.

    FF_SCRIPT

    Fonts designed to look like handwriting, for example, Script and Cursive.

    FF_SWISS

    Fonts with variable stroke width (proportional) and without serifs, for example, Sans Serif.

  • lfFaceName
    Specifies a null-terminated string that specifies the typeface name of the font. The length of this string must not exceed 32 characters, including the terminating null character. The EnumFontFamilies function can be used to enumerate the typeface names of all currently available fonts. If lfFaceName is an empty string, GDI uses the first font that matches the other specified attributes.

Remarks

Windows CE 1.0 and 1.01 do not support the following values for lfClipPrecision:

  • CLIP_MASK
  • CLIP_EMBEDDED
  • CLIP_LH_ANGLES
  • CLIP_TT_ALWAYS

Windows CE 2.0 and later ignore the lfClipPrecision and lfQuality members with one important exception. If the raster font engine is installed, an IfClipPrecision value of CLIP_CHARACTER_PRECIS will cause functions that create and select fonts to fail.

ClearType and antialiasing fonts are not available on surfaces that do not match the primary surface in both bit depth and the color masks. Drawing text to surfaces which do not match the primary surface results in draft quality text.

Requirements

Header wingdi.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

See Also

Reference

CreateFontIndirect
EnumFontFamilies