int EnumFonts(hDC,lpFacename,lpFontFunc,lpData)
This function enumerates the fonts available on a given device. For each font having the typeface name specified by the lpFacename parameter, the EnumFonts function retrieves information about that font and passes it to the function pointed to by the lpFontFunc parameter. The application-supplied callback function can process the font information as desired. Enumeration continues until there are no more fonts or the callback function returns zero.
Parameter | Type/Description |
hDC | HDC Identifies the device context. | |
lpFacename | LPSTR Points to a null-terminated character string that specifies the typeface name of the desired fonts. If lpFacename is NULL, EnumFonts randomly selects and enumerates one font of each available typeface. | |
lpFontFunc | FARPROC Is the procedure-instance address of the callback function. See the following “Comments” section for details. | |
lpData | LPSTR Points to the application-supplied data. The data is passed to the callback function along with the font information. |
The return value specifies the last value returned by the callback function. Its meaning is user-defined.
The address passed as the lpFontFunc parameter must be created by using the MakeProcInstance function.
The callback function must use the Pascal calling convention and must be declared FAR.
int FAR PASCAL FontFunc(lpLogFont, lpTextMetrics, nFontType, lpData)
LPLOGFONT lpLogFont;
LPTEXTMETRICS lpTextMetrics;
short nFontType;
LPSTR lpData;
FontFunc is a placeholder for the application-supplied function name. The actual name must be exported by including it in an EXPORTS statement in the application's module-definition file.
Parameter | Description |
lpLogFont | Points to a LOGFONT data structure that contains information about the logical attributes of the font. | |
lpTextMetrics | Points to a TEXTMETRIC data structure that contains information about the physical attributes of the font. | |
nFontType | Specifies the type of the font. | |
lpData | Points to the application-supplied data passed by EnumFonts. |
Return Value
The return value can be any integer.
Comments
The AND (&) operator can be used with the RASTER_FONTTYPE and DEVICE_FONTTYPE constants to determine the font type. The RASTER_FONTTYPE bit of the FontType parameter specifies whether the font is a raster or vector font. If the bit is one, the font is a raster font; if zero, it is a vector font. The DEVICE_FONTTYPE bit of FontType specifies whether the font is a device- or GDI-based font. If the bit is one, the font is a device-based font; if zero, it is a GDI-based font.
If the device is capable of text transformations (scaling, italicizing, and so on) only the base font will be enumerated. The user must inquire into the device's text-transformation abilities to determine which additional fonts are available directly from the device. GDI can simulate the bold, italic, underlined, and strikeout attributes for any GDI-based font.
EnumFonts only enumerates fonts from the GDI internal table. This does not include fonts that are generated by a device, such as fonts that are transformations of fonts from the internal table. The GetDeviceCaps function can be used to determine which trans-formations a device can perform. This information is available by using the TEXTCAPS index.
GDI can scale GDI-based raster fonts by one to five horizontally and one to eight vertically, unless PROOF_QUALITY is being used.