I have been trying to get a list of installed fonts on Windows including font style.
After investigation, I found out that I need to use: EnumFontFamiliesEx. I use it BUT I get only the font name and not all the styles of this font.
for example: for font: "Verdana"
There are four different styles, But I get only one - the regular. My question is: how can I get the fonts list including all the styles?
My code:
void getFonts()
{
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
lf.lfCharSet = DEFAULT_CHARSET;
HDC hDC = GetDC(NULL);
EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)(EnumFontFamExProc), NULL, 0);
}
int CALLBACK EnumFontFamExProc(
ENUMLOGFONTEX *lpelfe,
NEWTEXTMETRICEX *lpntme,
DWORD FontType,
LPARAM lParam
)
{
UTF8String fontName = (lpelfe->elfFullName);
return 1;
}
ENUMLOGFONTEX *lpelfe - contains the font. but I don't get all the different styles
after more investigation, I found out that if I change the lfFaceName to a specific font the method returns all styles.
// To enumerate all styles of all fonts for the ANSI character set
lf.lfFaceName[0] = '\0';
lf.lfCharSet = ANSI_CHARSET;
// To enumerate all styles of Arial font that cover the ANSI charset
hr = StringCchCopy( (LPSTR)lf.lfFaceName, LF_FACESIZE, "Arial" );
So I'm not sure what I should do, I need to get all the styles for all the installed fonts.
Thank you in advance
