gdi: Fix display of certain codepages

David Moore davidm at sjsoft.com
Thu Dec 15 13:11:03 CST 2005


This is a corrected patch.  The original was submitted yesterday.

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.  
It has been adjusted to only check for UTF7, UTF8 and SYMBOL, as these 
are the codepages that Wine supports.  Before this patch, Symbol fonts 
did not display correctly under certain circumstances, and presumably 
neither did UTF7 or UTF8 fonts (as shown by AstroGadget font in the 
Solar Fire Deluxe application).  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 15 Dec 2005 19:03:36 -0000
@@ -2679,14 +2679,38 @@
     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 CP_UTF7:
+       case CP_UTF8:
+       case CP_SYMBOL:
+           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