Fully initialize NEWTEXTMETRICEXW structure for bitmap fonts. Take 2

Dmitry Timoshkov dmitry at baikal.ru
Mon Dec 20 19:51:11 CST 2004


Hello,

this time I wrote a test program to see what values Windows returns for
bitmap fonts.

With this patch applications stop to show incorrect font attributes (like
OpenType logo) for bitmap fonts.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Fully initialize NEWTEXTMETRICEXW structure for bitmap fonts.

diff -up cvs/hq/wine/dlls/gdi/font.c wine/dlls/gdi/font.c
--- cvs/hq/wine/dlls/gdi/font.c	2004-09-08 17:35:53.000000000 +0900
+++ wine/dlls/gdi/font.c	2004-12-20 19:41:41.000000000 +0800
@@ -126,7 +126,7 @@ typedef struct
  */
 #define FS(x) {{0,0,0,0},{0x1<<(x),0}}
 #define MAXTCIINDEX 32
-static CHARSETINFO FONT_tci[MAXTCIINDEX] = {
+static const CHARSETINFO FONT_tci[MAXTCIINDEX] = {
   /* ANSI */
   { ANSI_CHARSET, 1252, FS(0)},
   { EASTEUROPE_CHARSET, 1250, FS(1)},
diff -up cvs/hq/wine/dlls/gdi/freetype.c wine/dlls/gdi/freetype.c
--- cvs/hq/wine/dlls/gdi/freetype.c	2004-12-15 20:43:24.000000000 +0800
+++ wine/dlls/gdi/freetype.c	2004-12-21 09:40:27.000000000 +0800
@@ -2032,16 +2032,16 @@ static void GetEnumStructs(Face *face, L
     if(!(ptm->tmPitchAndFamily & TMPF_VECTOR))
         *ptype |= RASTER_FONTTYPE;
 
-    if(potm) {
-        pntm->ntmTm.ntmFlags = ptm->tmItalic ? NTM_ITALIC : 0;
-        if(ptm->tmWeight > 550) pntm->ntmTm.ntmFlags |= NTM_BOLD;
-        if(pntm->ntmTm.ntmFlags == 0) pntm->ntmTm.ntmFlags = NTM_REGULAR;
+    pntm->ntmTm.ntmFlags = ptm->tmItalic ? NTM_ITALIC : 0;
+    if(ptm->tmWeight > 550) pntm->ntmTm.ntmFlags |= NTM_BOLD;
+    if(pntm->ntmTm.ntmFlags == 0) pntm->ntmTm.ntmFlags = NTM_REGULAR;
+
+    pntm->ntmTm.ntmCellHeight = pntm->ntmTm.tmHeight;
+    pntm->ntmTm.ntmAvgWidth = pntm->ntmTm.tmAveCharWidth;
+    memset(&pntm->ntmFontSig, 0, sizeof(FONTSIGNATURE));
 
+    if(potm) {
         pntm->ntmTm.ntmSizeEM = potm->otmEMSquare;
-        pntm->ntmTm.ntmCellHeight = 0;
-        pntm->ntmTm.ntmAvgWidth = 0;
-
-        memset(&pntm->ntmFontSig, 0, sizeof(FONTSIGNATURE));
 
         strncpyW(pelf->elfLogFont.lfFaceName,
                  (WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpFamilyName),
@@ -2053,7 +2053,10 @@ static void GetEnumStructs(Face *face, L
                  (WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpStyleName),
                  LF_FACESIZE);
 
+        HeapFree(GetProcessHeap(), 0, potm);
     } else {
+        pntm->ntmTm.ntmSizeEM = pntm->ntmTm.tmHeight - pntm->ntmTm.tmInternalLeading;
+
         strncpyW(pelf->elfLogFont.lfFaceName, face->family->FamilyName, LF_FACESIZE);
         strncpyW(pelf->elfFullName, face->family->FamilyName, LF_FACESIZE);
         pelf->elfStyle[0] = '\0';
@@ -2061,9 +2064,7 @@ static void GetEnumStructs(Face *face, L
 
     pelf->elfScript[0] = '\0'; /* This will get set in WineEngEnumFonts */
 
-    HeapFree(GetProcessHeap(), 0, potm);
     free_font(font);
-    return;
 }
 
 /*************************************************************






More information about the wine-patches mailing list