Enumerating Fonts (Windows Embedded CE 6.0)

1/6/2010

Your OS design can contain a number of fonts. Windows Embedded CE provides six standard logical fonts. You can use the GetStockObject function to obtain a standard font. The following table shows the standard font values.

Value Description

ANSI_FIXED_FONT

Specifies a monospace font based on the Windows character set, usually represented by a Courier font.

ANSI_VAR_FONT

Specifies a proportional font based on the Windows character set, usually represented by the MS Sans Serif font.

DEVICE_DEFAULT_FONT

Specifies the preferred font for the specified device, usually represented by the System font for display devices.

OEM_FIXED_FONT

Specifies a monospace font based on an OEM character set.

SYSTEM_FONT

Specifies the System font. This is a proportional font based on the Windows character set and is used by the operating system to display window titles, menu names, and text in dialog boxes. The System font is always available. Other fonts are available only if installed.

You can enumerate the fonts available on your system by calling the EnumFonts or EnumFontFamilies function. These functions send information about the available fonts to a callback function that the application supplies. The callback function stores the information in the LOGFONT structure and in either the NEWTEXTMETRIC structure for TrueType fonts or the TEXTMETRIC structure for raster fonts. By using the information returned from these functions, you can limit the user's choices to available fonts only.

The EnumFontFamilies function is similar to the EnumFonts function, but it includes some extra functionalities for use with TrueType fonts. The EnumFontFamilies function enumerates all the styles associated with a specified typeface, not simply the bold and italic attributes. For example, when the system includes a TrueType font called Courier New Extra-Bold, EnumFontFamilies lists it with the other Courier New fonts.

Note

Despite its name, EnumFontFamilies actually enumerates the styles associated with a specified typeface, such as Arial, rather than a font family, such as Swiss.

If you do not supply a typeface name, the EnumFonts and EnumFontFamilies functions supply information about one font in each available typeface. To enumerate all the fonts in a device context, you can specify NULL for the typeface name, compile a list of the available typefaces, and then enumerate each font in each typeface.

See Also

Other Resources

Fonts Application Development