int EnumFontFamilies(hdc, lpszFamily, fntenmprc, lParam) | |||||
HDC hdc; | /* handle of device context | */ | |||
LPCSTR lpszFamily; | /* address of font-family name | */ | |||
FONTENUMPROC fntenmprc; | /* address of callback function | */ | |||
LPARAM lParam; | /* application-defined data | */ |
The EnumFontFamilies function enumerates the fonts in a specified font family that are available on a given device. EnumFontFamilies continues until there are no more fonts or the callback function returns zero.
hdc
Identifies the device context.
lpszFamily
Points to a null-terminated string that specifies the family name of the desired fonts. If this parameter is NULL, the EnumFontFamilies function selects and enumerates one font from each available font family.
fntenmprc
Specifies the procedure-instance address of the application-defined callback function. The address must be created by the MakeProcInstance function. For more information about the callback function, see the description of the EnumFontFamProc callback function.
lParam
Specifies a 32-bit application-defined value that is passed to the callback function along with the font information.
The return value specifies the last value returned by the callback function, if the function is successful. This value depends on which font families are available for the given device.
The EnumFontFamilies function differs from the EnumFonts function in that it retrieves the style names associated with a TrueType font. Using EnumFontFamilies, an application can retrieve information about unusual font styles (for example, Outline) that cannot be enumerated by using the EnumFonts function. Applications should use EnumFontFamilies instead of EnumFonts.
For each font having the font name specified by the lpszFamily parameter, the EnumFontFamilies function retrieves information about that font and passes it to the function pointed to by the fntenmprc parameter. The application-supplied callback function can process the font information, as necessary.
The following example uses the MakeProcInstance function to create a pointer to the callback function for the EnumFontFamilies function. The FreeProcInstance function is called when enumeration is complete. Because the second parameter is NULL, EnumFontFamilies enumerates one font from each family that is available in the given device context. The aFontCount variable points to an array that is used inside the callback function.
FONTENUMPROC lpEnumFamCallBack;
int aFontCount[] = { 0, 0, 0 };
lpEnumFamCallBack = (FONTENUMPROC) MakeProcInstance(
(FARPROC) EnumFamCallBack, hAppInstance);
EnumFontFamilies(hdc, NULL, lpEnumFamCallBack, (LPARAM) aFontCount);
FreeProcInstance((FARPROC) lpEnumFamCallBack);