EnumFontFamProc

3.1

  int CALLBACK EnumFontFamProc(lpnlf, lpntm, FontType, lParam)    
  LOGFONT FAR* lpnlf; /* address of structure with logical-font data */
  TEXTMETRIC FAR* lpntm; /* address of structure with physical-font data */
  int FontType; /* type of font, */  
  LPARAM lParam; /* address of application-defined data */

The EnumFontFamProc function is an application-defined callback function that retrieves information about available fonts.

Parameters

lpnlf

Points to a NEWLOGFONT structure that contains information about the logical attributes of the font. This structure is locally-defined and is identical to the Windows LOGFONT structure except for two new members. The NEWLOGFONT structure has the following form:

struct tagNEWLOGFONT {                 /* nlf */
    int   lfHeight;
    int   lfWidth;
    int   lfEscapement;
    int   lfOrientation;
    int   lfWeight;
    BYTE  lfItalic;
    BYTE  lfUnderline;
    BYTE  lfStrikeOut;
    


    BYTE  lfCharSet;
    BYTE  lfOutPrecision;
    BYTE  lfClipPrecision;
    BYTE  lfQuality;
    BYTE  lfPitchAndFamily;
    BYTE  lfFaceName[LF_FACESIZE];
    BYTE  lfFullName[2 * LF_FACESIZE]; /* TrueType only */
    BYTE  lfStyle[LF_FACESIZE];        /* TrueType only */
} NEWLOGFONT;

The lfFullName and lfStyle members are appended to a LOGFONT structure when a TrueType font is enumerated in the EnumFontFamProc function.

The lfFullName member is a character array specifying the full name for the font. This name contains the font name and style name.

The lfStyle member is a character array specifying the style name for the font.

For example, when bold italic Arial̉ is enumerated, the last three members of the NEWLOGFONT structure contain the following strings:

lfFaceName = “Arial”; lfFullName = “Arial Bold Italic”; lfStyle = “Bold Italic”;

For a full description of the LOGFONT structure, see the Microsoft Windows Programmer's Reference, Volume 3.

lpntm

Points to a NEWTEXTMETRIC structure that contains information about the physical attributes of the font, if the font is a TrueType font. If the font is not a TrueType font, this parameter points to a TEXTMETRIC structure.

The NEWTEXTMETRIC structure has the following form:

typedef struct tagNEWTEXTMETRIC {   /* ntm */
    int   tmHeight;
    int   tmAscent;
    int   tmDescent;
    int   tmInternalLeading;
    int   tmExternalLeading;
    int   tmAveCharWidth;
    int   tmMaxCharWidth;
    int   tmWeight;
    BYTE  tmItalic;
    BYTE  tmUnderlined;
    BYTE  tmStruckOut;
    BYTE  tmFirstChar;
    BYTE  tmLastChar;
    BYTE  tmDefaultChar;
    BYTE  tmBreakChar;
    BYTE  tmPitchAndFamily;


    BYTE  tmCharSet;
    int   tmOverhang;
    int   tmDigitizedAspectX;
    int   tmDigitizedAspectY;
    DWORD ntmFlags;
    UINT  ntmSizeEM;
    UINT  ntmCellHeight;
    UINT  ntmAvgWidth;
} NEWTEXTMETRIC;

The TEXTMETRIC structure is identical to NEWTEXTMETRIC except that it does not include the last four members. For a full description of these structures, see the Microsoft Windows Programmer's Reference, Volume 3.

FontType

Specifies the type of the font. This parameter can be a combination of the following masks:

DEVICE_FONTTYPE RASTER_FONTTYPE TRUETYPE_FONTTYPE

lParam

Points to the application-defined data passed by EnumFontFamilies.

Return Value

This function must return a nonzero value to continue enumeration; to stop enumeration, it must return zero.

Comments

An application must register this callback function by passing its address to the EnumFontFamilies function. The EnumFontFamProc function is a placeholder for the application-defined function name. The actual name must be exported by including it in an EXPORTS statement in the application's module-definition (.DEF) file.

The AND (&) operator can be used with the RASTER_FONTTYPE, DEVICE_FONTTYPE, and TRUETYPE_FONTTYPE constants to determine the font type. If the RASTER_FONTTYPE bit is set, the font is a raster font. If the TRUETYPE_FONTTYPE bit is set, the font is a TrueType font. If neither bit is set, the font is a vector font. A third mask, DEVICE_FONTTYPE, is set when a device (for example, a laser printer) supports downloading TrueType fonts; it is zero if the font is not a device font. (Any device can support device fonts, including display adapters and dot-matrix printers.) An application can also use the DEVICE_FONTTYPE mask to distinguish GDI-supplied raster fonts from device-supplied fonts. GDI can simulate bold, italic, underline, and strikeout attributes for GDI-supplied raster fonts, but not for device-supplied fonts.

See Also

EnumFontFamilies, EnumFonts