Fix dsiplay of fonts with Symbol codepages (codepage 42) as well
David Moore
davidm at sjsoft.com
Wed Dec 14 03:42:32 CST 2005
As of this patch: http://cvs.winehq.org/patch.py?id=20043, displaying
fonts which use the Symbol codepage (codepage 42) has been broken. An
example of such a font is obtainable here:
http://www.rodsuskin.co.za/AstroGadget.ttf. This is due to the use of
the WideCharToMultiByte function. MSDN documentation on this function,
obtainable here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_2bj9.asp,
states that for certain codepages (including codepage 42), both the last
arguments have to be NULL. The patch above uses the last argument to
check if the default character was used, thus breaking the call for all
the codepages documented (GetLastError reports an ERROR_INVALID_PARAMETERS).
The patch below first checks to see if the codepage is one of the
exceptions, and if it is, passes in NULLs for the last two arguments.
Before this patch, all Symbol fonts did not display correctly. Now,
they do.
Changelog:
* dlls/gdi/freetype.c:
gdi: Fix display of fonts using Symbol codepages and assorted other
codepages
Patch:
Index: dlls/gdi/freetype.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/freetype.c,v
retrieving revision 1.107
diff -u -r1.107 freetype.c
--- dlls/gdi/freetype.c 1 Dec 2005 11:58:23 -0000 1.107
+++ dlls/gdi/freetype.c 14 Dec 2005 09:34:52 -0000
@@ -2679,14 +2679,55 @@
return;
}
+/***************************************************
+ * According to the MSDN documentation on WideCharToMultiByte,
+ * certain codepages cannot set the default_used parameter.
+ * This returns TRUE if the codepage can set that parameter, false else
+ * so that calls to WideCharToMultiByte don't fail with
ERROR_INVALID_PARAMETER
+ */
+static BOOL codepage_sets_default_used(UINT codepage)
+{
+ switch (codepage)
+ {
+ case 50220:
+ case 50221:
+ case 50222:
+ case 50225:
+ case 50227:
+ case 50229:
+ case 52936:
+ case 54936:
+ case 57002:
+ case 57003:
+ case 57004:
+ case 57005:
+ case 57006:
+ case 57007:
+ case 57008:
+ case 57009:
+ case 57010:
+ case 57011:
+ case 65000:
+ case 42:
+ return FALSE;
+ default:
+ return TRUE;
+ }
+}
+
static FT_UInt get_glyph_index(GdiFont font, UINT glyph)
{
if(font->ft_face->charmap->encoding == FT_ENCODING_NONE) {
WCHAR wc = (WCHAR)glyph;
BOOL default_used;
+ BOOL *default_used_pointer;
FT_UInt ret;
char buf;
- if(!WideCharToMultiByte(font->codepage, 0, &wc, 1, &buf,
sizeof(buf), NULL, &default_used) || default_used)
+ default_used_pointer = NULL;
+ default_used = FALSE;
+ if (codepage_sets_default_used(font->codepage))
+ default_used_pointer = &default_used;
+ if(!WideCharToMultiByte(font->codepage, 0, &wc, 1, &buf,
sizeof(buf), NULL, default_used_pointer) || default_used)
ret = 0;
else
ret = pFT_Get_Char_Index(font->ft_face, (unsigned char)buf);
More information about the wine-patches
mailing list