Enumerating Fonts in Windows Mobile

Download the source code

To enumerate installed fonts in Windows Mobile, we can use the APIs EnumFonts or EnumFontFamiliesEx. The EnumFontFamiliesEx API is preferred than EnumFonts. The syntax of the EnumFontFamiliesEx is:

int EnumFontFamiliesEx(HDC hdc,LPLOGFONT lpLogfont,
FONTENUMPROC lpEnumFontFamExProc,LPARAM lParam,DWORD dwFlags);

The first parameter is the handle to a Device Context. The second parameter s pointer to a LOGFONT structure. Only lfCharset, lfFaceName, lfPitchAndFamily members are important. The third parameter is pointer to the callback function which will be called for each font found while enumerating. Fourth an parameter is application defined value which will be passed to the callback function. Fifth parameter should be 0 and is not used.

The syntax of the callback function is:


The first parameter will be a pointer to ENUMLOGFONTEX structure which contains the font information. The second parameter is a pointer to the TEXTMETRIC structure which contains the attributes of the font. The third parameter is the type of the font which will be DEVICE_FONTTYPE, RASTER_FONTTYPE or TRUETYPE_FONTTYPE. The fourth parameter is the application defined lParam value.

The sample application presented here enumerate all the fonts installed in the device. The EnumFontFamiliesEx is called two times. First to get all the face name and second to enumerate all the fonts of each face name.

Leave a Reply

Your email address will not be published. Required fields are marked *