Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function enumerates all fonts in the system that match the font characteristics specified by the LOGFONTstructure. EnumFontFamiliesExenumerates fonts based on typeface name, character set, or both.
Syntax
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 LOGFONTstructure 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. The callback function is used to process the fonts and is called once for each enumerated font.
- 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 Value
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 EnumFontFamiliesExfunction 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 values of the lfCharsetand lfFacenamemembers in the LOGFONTstructure.
As with EnumFontFamilies, EnumFontFamiliesExenumerates 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 is 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 lfCharSetand 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.
Copy Code | |
---|---|
//To enumerate all styles and charsets of all fonts: lf.lfFaceName[0] = '\0'; lf.lfCharSet = DEFAULT_CHARSET; HRESULT hr; //To enumerate all styles and character sets of the Arial font: hr = StringCchCopy( (LPSTR)&lf.lfFaceName, 6, "Arial" ); if (FAILED(hr)) { // TODO: write error handler } 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: hr = StringCchCopy( (LPSTR)&lf.lfFaceName, 6, "Arial" ); if (FAILED(hr)) { // Handle errors appropriately } lf.lfCharSet = ANSI_CHARSET; |
The callback functions for EnumFontFamiliesand EnumFontFamiliesExare very similar.
Based on the values of lfCharSetand lfFaceName, EnumFontFamiliesExwill enumerate the same font as many times as there are distinct character sets in the font. This can create an extensive list of fonts that 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.
The fonts for many East Asian languages have two typeface names: an English name and a localized name. EnumFonts, EnumFontFamilies, and EnumFontFamiliesExreturn the English typeface name if the system locale does not match the language of the font.
Requirements
Header | wingdi.h |
Library | coredll.lib |
Windows Embedded CE | Windows CE 5.0 and later |
Windows Mobile | Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later |