tags:

views:

135

answers:

2

I've explored a bit, and so far I've found EnumFontFamiliesEx(...). However, it looks like this function is used to return all the charsets for a given font (e.g. "Arial").

I can't quite figure out how to get the list of installed fonts to begin with. Any help/suggestions would be appreciated.

Thank you in advance.

+1  A: 

You might want to take a look here, as the code there explains how to use the EnumFontFamiliesEx to get all the font names.

Paulo Santos
+1  A: 

You can do it something like this:

LOGFONT lf;
lf.lfFaceName[0] = '\0';
lf.lfCharSet = DEFAULT_CHARSET;
HDC hDC = ::GetDC();
EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)&EnumFontFamExProc, 0, 0);
ReleaseDC(hDC);

Then define a callback function:

int CALLBACK EnumFontFamExProc(
   ENUMLOGFONTEX *lpelfe,
  NEWTEXTMETRICEX *lpntme,
  DWORD FontType,
  LPARAM lParam
  )
{
    AfxMessageBox(lpelfe->elfFullName);

    //Return non--zero to continue enumeration
    return 1;
}
Naveen