EnumFontFamiliesEx
The EnumFontFamiliesEx function enumerates all fonts in the system that match the font characteristics specified by the LOGFONT structure. EnumFontFamiliesEx enumerates fonts based on typeface name, character set, or both.
int EnumFontFamiliesEx(
HDC hdc, // handle to DC
LPLOGFONT lpLogfont, // font information
FONTENUMPROC lpEnumFontFamExProc, // callback function
LPARAM lParam, // additional data
DWORD dwFlags // not used; must be 0
);
Parameters
hdc
[in] Handle to the device context.
lpLogfont
[in] Pointer to a LOGFONT structure that contains information about the fonts to enumerate. The function examines the following members. Member Description
lfCharset If set to DEFAULT_CHARSET, the function enumerates all fonts in all character sets. If set to a valid character set value, the function enumerates only fonts in the specified character set.
lfFaceName If set to an empty string, the function enumerates one font in each available typeface name. If set to a valid typeface name, the function enumerates all fonts with the specified name.
lfPitchAndFamily Must be set to zero for all language versions of the operating system.
lpEnumFontFamExProc
[in] Pointer to the application defined–callback function. For more information, see the EnumFontFamExProc function.
lParam
[in] Specifies an application–defined value. The function passes this value to the callback function along with font information.
dwFlags
This parameter is not used and must be zero.
Return Values
The return value is the last value returned by the callback function. This value depends on which font families are available for the specified device.
Remarks
The EnumFontFamiliesEx function does not use tagged typeface names to identify character sets. Instead, it always passes the correct typeface name and a separate character set value to the callback function. The function enumerates fonts based on the the values of the lfCharset and lfFacename members in the LOGFONT structure.
As with EnumFontFamilies, EnumFontFamiliesEx enumerates all font styles. Not all styles of a font cover the same character sets. For example, Fontorama Bold might contain ANSI, Greek, and Cyrillic characters, but Fontorama Italic might contain only ANSI characters. For this reason, it's best not to assume that a specified font covers a specific character set, even if it is the ANSI character set. The following table shows the results of various combinations of values for lfCharSet and lfFaceName.
Values Meaning
lfCharSet = DEFAULT_CHARSET
lfFaceName = '\0' Enumerates all fonts in all character sets.
lfCharSet = DEFAULT_CHARSET
lfFaceName = a specific font Enumerates all character sets and styles in a specific font.
lfCharSet =a specific character set
lfFaceName = '\0' Enumerates all styles of all fonts in the specific character set.
lfCharSet =a specific character set
lfFaceName = a specific font Enumerates all styles of a font in a specific character set.
The following code sample shows how these values are used.
//to enumerate all styles and charsets of all fonts:
lf.lfFaceName[0] = '\0';
lf.lfCharSet = DEFAULT_CHARSET;
//to enumerate all styles and character sets of the Arial font:
lstrcpy( (LPSTR)&lf.lfFaceName, "Arial" );
lf.lfCharSet = DEFAULT_CHARSET;
//to enumerate all styles of all fonts for the ANSI character set
lf.lfFaceName[0] = '\0';
lf.lfCharSet = ANSI_CHARSET;
//to enumerate all styles of Arial font that cover the ANSI charset
lstrcpy( (LPSTR)&lf.lfFaceName, "Arial" );
lf.lfCharSet = ANSI_CHARSET;
The callback functions for EnumFontFamilies and EnumFontFamiliesEx are very similar. The main difference is that the ENUMLOGFONTEX structure includes a script field.
Note, based on the values of lfCharSet and lfFaceName, EnumFontFamiliesEx will enumerate the same font as many times as there are distinct character sets in the font. This can create an extensive list of fonts which can be burdensome to a user. For example, the Century Schoolbook font can appear for the Baltic, Western, Greek, Turkish, and Cyrillic character sets. To avoid this, an application should filter the list of fonts.
Requirements
Windows NT/2000: Requires Windows NT 4.0 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
See Also
Fonts and Text Overview, Font and Text Functions, EnumFontFamExProc, LOGFONT
Built on Wednesday, February 09, 2000Requirements
Windows NT/2000: Requires Windows NT 4.0 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
See Also
Fonts and Text Overview, Font and Text Functions, EnumFontFamExProc, LOGFONT