http://bugs.winehq.org/show_bug.cgi?id=33117
--- Comment #8 from Robert Walker forums@robertinventor.com 2013-03-04 11:43:17 CST --- Here is another observation which may help.
I have just tried EnumFontFamiliesEx to find the character set of the font. On Windows it finds the Bach character set as 2 (for symbol). On Wine it finds it as 0.
Another font that differs between Wine and Windows is Arial Unicode MS which I use to display unicode characters.
On Windows it's character set is 0 On Wine it is 136.
Same issue, you get the wrong font selected if you use the wrong character set, gets Arial selected instead (the old non unicode version of Arial).
int EnumFontFindCharSet ( ENUMLOGFONTEX *lpelfe, // pointer to logical-font data NEWTEXTMETRICEX *lpntme, // pointer to physical-font data int FontType, // type of font LPARAM lParam // application-defined data ) { return lpelfe->elfLogFont.lfCharSet; }
int iCharSetForFontByEnum(LOGFONT lfFont) { // see: http://msdn.microsoft.com/en-us/library/windows/desktop/dd162620(v=vs.85).as... // If set to DEFAULT_CHARSET, the function enumerates all uniquely-named fonts in all character sets. int iCharSet=0; LOGFONT lfT=lfFont; HDC hdc=GetDC(NULL); lfT.lfCharSet=DEFAULT_CHARSET; iCharSet=EnumFontFamiliesEx(hdc,&lfT,(FONTENUMPROC) EnumFontFindCharSet,0L,0L); ReleaseDC(NULL,hdc); return iCharSet; }
I've also realised while coding this, that this approach is a way to guarantee that you get a named font if you don't know what its character set is.
You might think that it is enough to just set the character set to DEFAULT_CHARSET but that sets it to the default character set for your computer (not the default character set for the font name) when used in CreateFontIndirect and so doesn't help here, and is normally not recommended.
The use of DEFAULT_CHARSET to enumerate over all the available fonts is restricted to this particular use in EnumFontFamiliesEx as far as I know.