gdi: Fix display of certain codepages

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

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

As of this patch:, displaying 
fonts which use the Symbol codepage (codepage 42) has been broken.  An 
example of such a font is obtainable here:  This is due to the use of 
the WideCharToMultiByte function.  MSDN documentation on this function, 
obtainable here:, 
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 

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.


  * dlls/gdi/freetype.c:
  gdi: Fix display of fonts using Symbol codepages and assorted other 


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 @@

+ * 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 
+ */
+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;
             ret = pFT_Get_Char_Index(font->ft_face, (unsigned char)buf);

More information about the wine-patches mailing list