1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
class SomeClass
{
void add_font_to_list(char *facename, uint charset, u8 pitch, u8 family)
{
// do stuff
}
static int CALLBACK EnumFontFamiliesExProc(
ENUMLOGFONTEX *lpelfe,
NEWTIMXTMETRICEX *plntme,
DWORD FontType,
LPARAM lParam)
{
SomeClass* pThis = (SomeClass*)(void*)lParam;
LOGFONT *lfptr = &lpelfe->elfLogFont;
u8 paf = (u8) lfptr->lfPitchAndFamily;
u8 pitch = paf & 0x03;
u8 family = paf & 0xFC;
pThis->add_font_to_list((char *)lpelfe->elfFullName, lfptr->lfCharSet, pitch, family);
return 1;
}
build_font_list()
{
HDC hDC = GetDC(NULL);
LOGFONT lf = { 0, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, DEFAULT_PITCH, ""};
EnumFontFamiliesEx(hDC, &lf, EnumFontFamiliesExProc, (LPARAM)(void*)&this, 0 );
ReleaseDC(NULL, hDC);
}
//...
};
|