[Bug 33117] Can't load Bach41.ttf with CreateFontIndirect under Wine - this works fine in Windows

wine-bugs at winehq.org wine-bugs at winehq.org
Mon Mar 4 11:43:17 CST 2013


http://bugs.winehq.org/show_bug.cgi?id=33117

--- Comment #8 from Robert Walker <forums at 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).aspx
 // 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.

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list