gdi32: Add support for Type1 fonts.

Kusanagi Kouichi slash at ma.neweb.ne.jp
Tue Nov 13 10:47:20 CST 2007


Fix bug #697.  http://bugs.winehq.org/show_bug.cgi?id=697
---
 configure             |    4 +-
 configure.ac          |    3 +-
 dlls/gdi32/freetype.c |  416 +++++++++++++++++++++++++++++++++++--------------
 include/config.h.in   |    3 +
 4 files changed, 303 insertions(+), 123 deletions(-)

diff --git a/configure b/configure
index 6e3b3ae..b094e32 100755
--- a/configure
+++ b/configure
@@ -13156,6 +13156,7 @@ fi
 
 
 
+
 for ac_header in ft2build.h \
                          freetype/freetype.h \
                          freetype/ftglyph.h \
@@ -13167,7 +13168,8 @@ for ac_header in ft2build.h \
                          freetype/ftoutln.h \
                          freetype/ftwinfnt.h \
                          freetype/ftmodapi.h \
-                         freetype/internal/sfnt.h
+                         freetype/internal/sfnt.h \
+                         freetype/t1tables.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for $ac_header" >&5
diff --git a/configure.ac b/configure.ac
index 3d62f45..e23d705 100644
--- a/configure.ac
+++ b/configure.ac
@@ -896,7 +896,8 @@ then
                          freetype/ftoutln.h \
                          freetype/ftwinfnt.h \
                          freetype/ftmodapi.h \
-                         freetype/internal/sfnt.h,,,
+                         freetype/internal/sfnt.h \
+                         freetype/t1tables.h,,,
                          [#if HAVE_FT2BUILD_H
                           #include <ft2build.h>
                           #endif])
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index a79f41d..054a1fb 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -130,6 +130,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(font);
 #ifdef HAVE_FREETYPE_FTMODAPI_H
 #include <freetype/ftmodapi.h>
 #endif
+#ifdef HAVE_FREETYPE_T1TABLES_H
+#include <freetype/t1tables.h>
+#endif
 
 #ifndef HAVE_FT_TRUETYPEENGINETYPE
 typedef enum
@@ -181,6 +184,10 @@ static FT_TrueTypeEngineType (*pFT_Get_TrueType_Engine_Type)(FT_Library);
 #ifdef HAVE_FREETYPE_FTWINFNT_H
 MAKE_FUNCPTR(FT_Get_WinFNT_Header);
 #endif
+#ifdef HAVE_FREETYPE_T1TABLES_H
+MAKE_FUNCPTR(FT_Get_PS_Font_Info);
+MAKE_FUNCPTR(FT_Attach_File);
+#endif
 
 #ifdef SONAME_LIBFONTCONFIG
 #include <fontconfig/fontconfig.h>
@@ -1058,11 +1065,13 @@ static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_
 	    return 0;
 	}
 
+#if 0
 	if(!FT_IS_SFNT(ft_face) && (FT_IS_SCALABLE(ft_face) || !(flags & ADDFONT_FORCE_BITMAP))) { /* for now we'll accept TT/OT or bitmap fonts*/
 	    WARN("Ignoring font %s/%p\n", debugstr_a(file), font_data_ptr);
 	    pFT_Done_Face(ft_face);
 	    return 0;
 	}
+#endif
 
         /* There are too many bugs in FreeType < 2.1.9 for bitmap font support */
         if(!FT_IS_SCALABLE(ft_face) && FT_SimpleVersion < ((2 << 16) | (1 << 8) | (9 << 0))) {
@@ -1125,6 +1134,9 @@ static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_
         do {
             My_FT_Bitmap_Size *size = NULL;
             FT_ULong tmp_size;
+#ifdef HAVE_FREETYPE_T1TABLES_H
+            PS_FontInfoRec psfontinfo;
+#endif
 
             if(!FT_IS_SCALABLE(ft_face))
                 size = (My_FT_Bitmap_Size *)ft_face->available_sizes + bitmap_num;
@@ -1280,6 +1292,14 @@ static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_
                 TRACE("Font %s/%p is OTF Type1\n", wine_dbgstr_a(file), font_data_ptr);
                 face->ntmFlags = NTM_PS_OPENTYPE;
             }
+#ifdef HAVE_FREETYPE_T1TABLES_H
+            else if (pFT_Get_PS_Font_Info &&
+                     pFT_Get_PS_Font_Info(ft_face, &psfontinfo) == 0)
+            {
+                TRACE("Font %s/%p is Type1\n", wine_dbgstr_a(file), font_data_ptr);
+                face->ntmFlags = NTM_TYPE1;
+            }
+#endif
             else
                 face->ntmFlags = 0;
 
@@ -2130,6 +2150,10 @@ BOOL WineEngInit(void)
 #ifdef HAVE_FREETYPE_FTWINFNT_H
     pFT_Get_WinFNT_Header = wine_dlsym(ft_handle, "FT_Get_WinFNT_Header", NULL, 0);
 #endif
+#ifdef HAVE_FREETYPE_T1TABLES_H
+    pFT_Get_PS_Font_Info = wine_dlsym(ft_handle, "FT_Get_PS_Font_Info", NULL, 0);
+    pFT_Attach_File = wine_dlsym(ft_handle, "FT_Attach_File", NULL, 0);
+#endif
       if(!wine_dlsym(ft_handle, "FT_Get_Postscript_Name", NULL, 0) &&
 	 !wine_dlsym(ft_handle, "FT_Sqrt64", NULL, 0)) {
 	/* try to avoid 2.0.4: >= 2.0.5 has FT_Get_Postscript_Name and
@@ -2299,14 +2323,8 @@ sym_not_found:
 
 static LONG calc_ppem_for_height(FT_Face ft_face, LONG height)
 {
-    TT_OS2 *pOS2;
-    TT_HoriHeader *pHori;
-
     LONG ppem;
 
-    pOS2 = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_os2);
-    pHori = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_hhea);
-
     if(height == 0) height = 16;
 
     /* Calc. height of EM square:
@@ -2324,12 +2342,26 @@ static LONG calc_ppem_for_height(FT_Face ft_face, LONG height)
      */
 
     if(height > 0) {
-        if(pOS2->usWinAscent + pOS2->usWinDescent == 0)
-            ppem = ft_face->units_per_EM * height /
-                (pHori->Ascender - pHori->Descender);
+        TT_OS2 *pOS2;
+        TT_HoriHeader *pHori;
+
+        pOS2 = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_os2);
+        pHori = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_hhea);
+
+        if (pOS2 && pHori)
+        {
+            if(pOS2->usWinAscent + pOS2->usWinDescent == 0)
+                ppem = ft_face->units_per_EM * height /
+                    (pHori->Ascender - pHori->Descender);
+            else
+                ppem = ft_face->units_per_EM * height /
+                    (pOS2->usWinAscent + pOS2->usWinDescent);
+        }
         else
+        {
             ppem = ft_face->units_per_EM * height /
-                (pOS2->usWinAscent + pOS2->usWinDescent);
+                (ft_face->bbox.yMax - ft_face->bbox.yMin);
+        }
     }
     else
         ppem = -height;
@@ -2396,6 +2428,9 @@ static FT_Face OpenFontFace(GdiFont *font, Face *face, LONG width, LONG height)
     FT_Face ft_face;
     void *data_ptr;
     DWORD data_size;
+#ifdef HAVE_FREETYPE_T1TABLES_H
+    PS_FontInfoRec psfontinfo;
+#endif
 
     TRACE("%s/%p, %ld, %d x %d\n", debugstr_a(face->file), face->font_data_ptr, face->face_index, width, height);
 
@@ -2424,6 +2459,22 @@ static FT_Face OpenFontFace(GdiFont *font, Face *face, LONG width, LONG height)
     /* set it here, as load_VDMX needs it */
     font->ft_face = ft_face;
 
+#ifdef HAVE_FREETYPE_T1TABLES_H
+    if (face->file && strlen(face->file) > 4 && pFT_Get_PS_Font_Info &&
+        pFT_Get_PS_Font_Info(ft_face, &psfontinfo) == 0)
+    {
+        char *afm;
+
+        afm = strdup(face->file);
+        if (afm)
+        {
+            strcpy(afm + strlen(afm) - 4, ".afm");
+            pFT_Attach_File(ft_face, afm);
+            free(afm);
+        }
+    }
+#endif
+
     if(FT_IS_SCALABLE(ft_face)) {
         /* load the VDMX table if we have one */
         font->ppem = load_VDMX(font, height);
@@ -4131,6 +4182,56 @@ BOOL WineEngGetTextMetrics(GdiFont *font, LPTEXTMETRICW ptm)
 }
 
 
+#ifdef HAVE_FREETYPE_T1TABLES_H
+static int psfontweight(const char *weight)
+{
+    if (strcmp(weight, "Regular") == 0)
+    {
+       return 400;
+    }
+    else if (strcmp(weight, "Bold") == 0)
+    {
+       return 700;
+    }
+    else if (strcmp(weight, "Very Light") == 0)
+    {
+       return 100;
+    }
+    else if (strcmp(weight, "Light") == 0)
+    {
+       return 200;
+    }
+    else if (strcmp(weight, "Thin") == 0)
+    {
+       return 300;
+    }
+    else if (strcmp(weight, "Book") == 0)
+    {
+       return 400;
+    }
+    else if (strcmp(weight, "Medium") == 0)
+    {
+       return 500;
+    }
+    else if (strcmp(weight, "Demi") == 0)
+    {
+       return 600;
+    }
+    else if (strcmp(weight, "Heavy") == 0)
+    {
+       return 800;
+    }
+    else if (strcmp(weight, "Black") == 0)
+    {
+       return 900;
+    }
+    else
+    {
+       return 400;
+    }
+}
+#endif
+
 /*************************************************************
  * WineEngGetOutlineTextMetrics
  *
@@ -4143,6 +4244,9 @@ UINT WineEngGetOutlineTextMetrics(GdiFont *font, UINT cbSize,
     TT_OS2 *pOS2;
     TT_HoriHeader *pHori;
     TT_Postscript *pPost;
+#ifdef HAVE_FREETYPE_T1TABLES_H
+    PS_FontInfoRec psfontinfo;
+#endif
     FT_Fixed x_scale, y_scale;
     WCHAR *family_nameW, *style_nameW;
     static const WCHAR spaceW[] = {' ', '\0'};
@@ -4195,41 +4299,45 @@ UINT WineEngGetOutlineTextMetrics(GdiFont *font, UINT cbSize,
     y_scale = ft_face->size->metrics.y_scale;
 
     pOS2 = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_os2);
-    if(!pOS2) {
-        FIXME("Can't find OS/2 table - not TT font?\n");
-	ret = 0;
-	goto end;
-    }
-
     pHori = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_hhea);
-    if(!pHori) {
-        FIXME("Can't find HHEA table - not TT font?\n");
-	ret = 0;
-	goto end;
+    if(pOS2 && pHori) {
+        pPost = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_post); /* we can live with this failing */
+
+        TRACE("OS/2 winA = %d winD = %d typoA = %d typoD = %d typoLG = %d FT_Face a = %d, d = %d, h = %d: HORZ a = %d, d = %d lg = %d maxY = %ld minY = %ld\n",
+              pOS2->usWinAscent, pOS2->usWinDescent,
+              pOS2->sTypoAscender, pOS2->sTypoDescender, pOS2->sTypoLineGap,
+              ft_face->ascender, ft_face->descender, ft_face->height,
+              pHori->Ascender, pHori->Descender, pHori->Line_Gap,
+              ft_face->bbox.yMax, ft_face->bbox.yMin);
+
+        if(pOS2->usWinAscent + pOS2->usWinDescent == 0) {
+            ascent = pHori->Ascender;
+            descent = -pHori->Descender;
+        } else {
+            ascent = pOS2->usWinAscent;
+            descent = pOS2->usWinDescent;
+        }
+    }
+#ifdef HAVE_FREETYPE_T1TABLES_H
+    else if (pFT_Get_PS_Font_Info &&
+             pFT_Get_PS_Font_Info(ft_face, &psfontinfo) == 0)
+    {
+        ascent = ft_face->bbox.yMax;
+        descent = -ft_face->bbox.yMin;
+    }
+#endif
+    else
+    {
+        FIXME("Can't find OS/2 table - not TT font?\n");
+        ret = 0;
+        goto end;
     }
-
-    pPost = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_post); /* we can live with this failing */
-
-    TRACE("OS/2 winA = %d winD = %d typoA = %d typoD = %d typoLG = %d FT_Face a = %d, d = %d, h = %d: HORZ a = %d, d = %d lg = %d maxY = %ld minY = %ld\n",
-	  pOS2->usWinAscent, pOS2->usWinDescent,
-	  pOS2->sTypoAscender, pOS2->sTypoDescender, pOS2->sTypoLineGap,
-	  ft_face->ascender, ft_face->descender, ft_face->height,
-	  pHori->Ascender, pHori->Descender, pHori->Line_Gap,
-	  ft_face->bbox.yMax, ft_face->bbox.yMin);
 
     font->potm = HeapAlloc(GetProcessHeap(), 0, needed);
     font->potm->otmSize = needed;
 
 #define TM font->potm->otmTextMetrics
 
-    if(pOS2->usWinAscent + pOS2->usWinDescent == 0) {
-        ascent = pHori->Ascender;
-        descent = -pHori->Descender;
-    } else {
-        ascent = pOS2->usWinAscent;
-        descent = pOS2->usWinDescent;
-    }
-
     if(font->yMax) {
 	TM.tmAscent = font->yMax;
 	TM.tmDescent = -font->yMin;
@@ -4242,74 +4350,169 @@ UINT WineEngGetOutlineTextMetrics(GdiFont *font, UINT cbSize,
     }
 
     TM.tmHeight = TM.tmAscent + TM.tmDescent;
-
-    /* MSDN says:
-     el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
-    */
-    TM.tmExternalLeading = max(0, (pFT_MulFix(pHori->Line_Gap -
-       		 ((ascent + descent) -
-		  (pHori->Ascender - pHori->Descender)), y_scale) + 32) >> 6);
-
-    TM.tmAveCharWidth = (pFT_MulFix(pOS2->xAvgCharWidth, x_scale) + 32) >> 6;
-    if (TM.tmAveCharWidth == 0) {
-        TM.tmAveCharWidth = 1; 
-    }
     TM.tmMaxCharWidth = (pFT_MulFix(ft_face->bbox.xMax - ft_face->bbox.xMin, x_scale) + 32) >> 6;
-    TM.tmWeight = font->fake_bold ? FW_BOLD : pOS2->usWeightClass;
     TM.tmOverhang = 0;
     TM.tmDigitizedAspectX = 300;
     TM.tmDigitizedAspectY = 300;
-    /* It appears that for fonts with SYMBOL_CHARSET Windows always sets
-     * symbol range to 0 - f0ff
-     */
-    if (font->charset == SYMBOL_CHARSET)
-        TM.tmFirstChar = 0;
-    else
-        TM.tmFirstChar = pOS2->usFirstCharIndex;
-    TM.tmLastChar = pOS2->usLastCharIndex;
-    TM.tmDefaultChar = pOS2->usDefaultChar ? pOS2->usDefaultChar : 0x1f;
-    TM.tmBreakChar = pOS2->usBreakChar ? pOS2->usBreakChar : ' ';
     TM.tmItalic = font->fake_italic ? 255 : ((ft_face->style_flags & FT_STYLE_FLAG_ITALIC) ? 255 : 0);
     TM.tmUnderlined = font->underline;
     TM.tmStruckOut = font->strikeout;
 
-    /* Yes TPMF_FIXED_PITCH is correct; braindead api */
-    if(!FT_IS_FIXED_WIDTH(ft_face) &&
-       (pOS2->version == 0xFFFFU || 
-        pOS2->panose[PAN_PROPORTION_INDEX] != PAN_PROP_MONOSPACED))
-        TM.tmPitchAndFamily = TMPF_FIXED_PITCH;
+#ifdef HAVE_FREETYPE_T1TABLES_H
+    if (pOS2 && pHori)
+    {
+#endif
+        /* MSDN says:
+         el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
+        */
+        TM.tmExternalLeading = max(0, (pFT_MulFix(pHori->Line_Gap -
+                     ((ascent + descent) -
+                      (pHori->Ascender - pHori->Descender)), y_scale) + 32) >> 6);
+
+        TM.tmAveCharWidth = (pFT_MulFix(pOS2->xAvgCharWidth, x_scale) + 32) >> 6;
+        if (TM.tmAveCharWidth == 0) {
+            TM.tmAveCharWidth = 1; 
+        }
+        TM.tmWeight = font->fake_bold ? FW_BOLD : pOS2->usWeightClass;
+        /* It appears that for fonts with SYMBOL_CHARSET Windows always sets
+         * symbol range to 0 - f0ff
+         */
+        if (font->charset == SYMBOL_CHARSET)
+            TM.tmFirstChar = 0;
+        else
+            TM.tmFirstChar = pOS2->usFirstCharIndex;
+        TM.tmLastChar = pOS2->usLastCharIndex;
+        TM.tmDefaultChar = pOS2->usDefaultChar ? pOS2->usDefaultChar : 0x1f;
+        TM.tmBreakChar = pOS2->usBreakChar ? pOS2->usBreakChar : ' ';
+
+        /* Yes TPMF_FIXED_PITCH is correct; braindead api */
+        if(!FT_IS_FIXED_WIDTH(ft_face) &&
+           (pOS2->version == 0xFFFFU || 
+            pOS2->panose[PAN_PROPORTION_INDEX] != PAN_PROP_MONOSPACED))
+            TM.tmPitchAndFamily = TMPF_FIXED_PITCH;
+        else
+            TM.tmPitchAndFamily = 0;
+
+        switch(pOS2->panose[PAN_FAMILYTYPE_INDEX]) {
+        case PAN_FAMILY_SCRIPT:
+            TM.tmPitchAndFamily |= FF_SCRIPT;
+            break;
+        case PAN_FAMILY_DECORATIVE:
+        case PAN_FAMILY_PICTORIAL:
+            TM.tmPitchAndFamily |= FF_DECORATIVE;
+            break;
+        case PAN_FAMILY_TEXT_DISPLAY:
+            if(TM.tmPitchAndFamily == 0) /* fixed */
+                TM.tmPitchAndFamily = FF_MODERN;
+            else {
+                switch(pOS2->panose[PAN_SERIFSTYLE_INDEX]) {
+                case PAN_SERIF_NORMAL_SANS:
+                case PAN_SERIF_OBTUSE_SANS:
+                case PAN_SERIF_PERP_SANS:
+                    TM.tmPitchAndFamily |= FF_SWISS;
+                    break;
+                default:
+                    TM.tmPitchAndFamily |= FF_ROMAN;
+                }
+            }
+            break;
+        default:
+            TM.tmPitchAndFamily |= FF_DONTCARE;
+        }
+
+        memcpy(&font->potm->otmPanoseNumber, pOS2->panose, PANOSE_COUNT);
+        font->potm->otmfsSelection = pOS2->fsSelection;
+        font->potm->otmfsType = pOS2->fsType;
+        font->potm->otmsCharSlopeRise = pHori->caret_Slope_Rise;
+        font->potm->otmsCharSlopeRun = pHori->caret_Slope_Run;
+        font->potm->otmItalicAngle = 0; /* POST table */
+        font->potm->otmAscent = (pFT_MulFix(pOS2->sTypoAscender, y_scale) + 32) >> 6;
+        font->potm->otmDescent = (pFT_MulFix(pOS2->sTypoDescender, y_scale) + 32) >> 6;
+        font->potm->otmLineGap = (pFT_MulFix(pOS2->sTypoLineGap, y_scale) + 32) >> 6;
+        font->potm->otmsCapEmHeight = (pFT_MulFix(pOS2->sCapHeight, y_scale) + 32) >> 6;
+        font->potm->otmsXHeight = (pFT_MulFix(pOS2->sxHeight, y_scale) + 32) >> 6;
+        font->potm->otmusMinimumPPEM = 0; /* TT Header */
+        font->potm->otmptSubscriptSize.x = (pFT_MulFix(pOS2->ySubscriptXSize, x_scale) + 32) >> 6;
+        font->potm->otmptSubscriptSize.y = (pFT_MulFix(pOS2->ySubscriptYSize, y_scale) + 32) >> 6;
+        font->potm->otmptSubscriptOffset.x = (pFT_MulFix(pOS2->ySubscriptXOffset, x_scale) + 32) >> 6;
+        font->potm->otmptSubscriptOffset.y = (pFT_MulFix(pOS2->ySubscriptYOffset, y_scale) + 32) >> 6;
+        font->potm->otmptSuperscriptSize.x = (pFT_MulFix(pOS2->ySuperscriptXSize, x_scale) + 32) >> 6;
+        font->potm->otmptSuperscriptSize.y = (pFT_MulFix(pOS2->ySuperscriptYSize, y_scale) + 32) >> 6;
+        font->potm->otmptSuperscriptOffset.x = (pFT_MulFix(pOS2->ySuperscriptXOffset, x_scale) + 32) >> 6;
+        font->potm->otmptSuperscriptOffset.y = (pFT_MulFix(pOS2->ySuperscriptYOffset, y_scale) + 32) >> 6;
+        font->potm->otmsStrikeoutSize = (pFT_MulFix(pOS2->yStrikeoutSize, y_scale) + 32) >> 6;
+        font->potm->otmsStrikeoutPosition = (pFT_MulFix(pOS2->yStrikeoutPosition, y_scale) + 32) >> 6;
+        if(!pPost) {
+            font->potm->otmsUnderscoreSize = 0;
+            font->potm->otmsUnderscorePosition = 0;
+        } else {
+            font->potm->otmsUnderscoreSize = (pFT_MulFix(pPost->underlineThickness, y_scale) + 32) >> 6;
+            font->potm->otmsUnderscorePosition = (pFT_MulFix(pPost->underlinePosition, y_scale) + 32) >> 6;
+        }
+#ifdef HAVE_FREETYPE_T1TABLES_H
+    }
     else
-        TM.tmPitchAndFamily = 0;
+    {
+        int weight = psfontweight(psfontinfo.weight);
+        FT_ULong first, last, next;
+        FT_UInt index;
+
+        first = pFT_Get_First_Char(ft_face, &index);
+        last = first;
+        while (next = pFT_Get_Next_Char(ft_face, last, &index), index)
+        {
+            last = next;
+        }
+
+        TM.tmExternalLeading = (pFT_MulFix(ft_face->height - (ascent + descent), y_scale) + 32) >> 6;
+        TM.tmAveCharWidth = 1;
+        TM.tmWeight = font->fake_bold ? FW_BOLD : weight;
+        TM.tmFirstChar = first;
+        TM.tmLastChar = last;
+        TM.tmDefaultChar = ' ';
+        TM.tmBreakChar = ' ';
+
+        /* Yes TPMF_FIXED_PITCH is correct; braindead api */
+        if(!FT_IS_FIXED_WIDTH(ft_face) && !psfontinfo.is_fixed_pitch)
+            TM.tmPitchAndFamily = TMPF_FIXED_PITCH;
+        else
+            TM.tmPitchAndFamily = 0;
 
-    switch(pOS2->panose[PAN_FAMILYTYPE_INDEX]) {
-    case PAN_FAMILY_SCRIPT:
-        TM.tmPitchAndFamily |= FF_SCRIPT;
-	break;
-    case PAN_FAMILY_DECORATIVE:
-    case PAN_FAMILY_PICTORIAL:
-        TM.tmPitchAndFamily |= FF_DECORATIVE;
-	break;
-    case PAN_FAMILY_TEXT_DISPLAY:
-        if(TM.tmPitchAndFamily == 0) /* fixed */
-	    TM.tmPitchAndFamily = FF_MODERN;
-	else {
-	    switch(pOS2->panose[PAN_SERIFSTYLE_INDEX]) {
-	    case PAN_SERIF_NORMAL_SANS:
-	    case PAN_SERIF_OBTUSE_SANS:
-	    case PAN_SERIF_PERP_SANS:
-	        TM.tmPitchAndFamily |= FF_SWISS;
-		break;
-	    default:
-	        TM.tmPitchAndFamily |= FF_ROMAN;
-	    }
-	}
-	break;
-    default:
         TM.tmPitchAndFamily |= FF_DONTCARE;
+
+        memset(&font->potm->otmPanoseNumber, 0, PANOSE_COUNT);
+        font->potm->otmPanoseNumber.bWeight = weight / 100 + 1;
+        if (psfontinfo.italic_angle)
+            font->potm->otmfsSelection = 1;
+        else
+            font->potm->otmfsSelection = 0;
+        if (weight > 550)
+            font->potm->otmfsSelection |= 0x20;
+        font->potm->otmfsType = 0;
+        font->potm->otmsCharSlopeRise = 1;
+        font->potm->otmsCharSlopeRun = 0;
+        font->potm->otmItalicAngle = psfontinfo.italic_angle;
+        font->potm->otmAscent = (pFT_MulFix(ascent, y_scale) + 32) >> 6;
+        font->potm->otmDescent = (pFT_MulFix(descent, y_scale) + 32) >> 6;
+        font->potm->otmLineGap = TM.tmExternalLeading;
+        font->potm->otmsCapEmHeight = 0;
+        font->potm->otmsXHeight = 0;
+        font->potm->otmptSubscriptSize.x = 0;
+        font->potm->otmptSubscriptSize.y = 0;
+        font->potm->otmptSubscriptOffset.x = 0;
+        font->potm->otmptSubscriptOffset.y = 0;
+        font->potm->otmptSuperscriptSize.x = 0;
+        font->potm->otmptSuperscriptSize.y = 0;
+        font->potm->otmptSuperscriptOffset.x = 0;
+        font->potm->otmptSuperscriptOffset.y = 0;
+        font->potm->otmsStrikeoutSize = 0;
+        font->potm->otmsStrikeoutPosition = font->potm->otmAscent / 3;
+        font->potm->otmsUnderscoreSize = (pFT_MulFix(ft_face->underline_thickness, y_scale) + 32) >> 6;
+        font->potm->otmsUnderscorePosition = (pFT_MulFix(ft_face->underline_position, y_scale) + 32) >> 6;
     }
+#endif
 
-    if(FT_IS_SCALABLE(ft_face))
-        TM.tmPitchAndFamily |= TMPF_VECTOR;
+    TM.tmPitchAndFamily |= TMPF_VECTOR;
 
     if(FT_IS_SFNT(ft_face))
     {
@@ -4323,18 +4526,7 @@ UINT WineEngGetOutlineTextMetrics(GdiFont *font, UINT cbSize,
 #undef TM
 
     font->potm->otmFiller = 0;
-    memcpy(&font->potm->otmPanoseNumber, pOS2->panose, PANOSE_COUNT);
-    font->potm->otmfsSelection = pOS2->fsSelection;
-    font->potm->otmfsType = pOS2->fsType;
-    font->potm->otmsCharSlopeRise = pHori->caret_Slope_Rise;
-    font->potm->otmsCharSlopeRun = pHori->caret_Slope_Run;
-    font->potm->otmItalicAngle = 0; /* POST table */
     font->potm->otmEMSquare = ft_face->units_per_EM;
-    font->potm->otmAscent = (pFT_MulFix(pOS2->sTypoAscender, y_scale) + 32) >> 6;
-    font->potm->otmDescent = (pFT_MulFix(pOS2->sTypoDescender, y_scale) + 32) >> 6;
-    font->potm->otmLineGap = (pFT_MulFix(pOS2->sTypoLineGap, y_scale) + 32) >> 6;
-    font->potm->otmsCapEmHeight = (pFT_MulFix(pOS2->sCapHeight, y_scale) + 32) >> 6;
-    font->potm->otmsXHeight = (pFT_MulFix(pOS2->sxHeight, y_scale) + 32) >> 6;
     font->potm->otmrcFontBox.left = (pFT_MulFix(ft_face->bbox.xMin, x_scale) + 32) >> 6;
     font->potm->otmrcFontBox.right = (pFT_MulFix(ft_face->bbox.xMax, x_scale) + 32) >> 6;
     font->potm->otmrcFontBox.top = (pFT_MulFix(ft_face->bbox.yMax, y_scale) + 32) >> 6;
@@ -4342,24 +4534,6 @@ UINT WineEngGetOutlineTextMetrics(GdiFont *font, UINT cbSize,
     font->potm->otmMacAscent = 0; /* where do these come from ? */
     font->potm->otmMacDescent = 0;
     font->potm->otmMacLineGap = 0;
-    font->potm->otmusMinimumPPEM = 0; /* TT Header */
-    font->potm->otmptSubscriptSize.x = (pFT_MulFix(pOS2->ySubscriptXSize, x_scale) + 32) >> 6;
-    font->potm->otmptSubscriptSize.y = (pFT_MulFix(pOS2->ySubscriptYSize, y_scale) + 32) >> 6;
-    font->potm->otmptSubscriptOffset.x = (pFT_MulFix(pOS2->ySubscriptXOffset, x_scale) + 32) >> 6;
-    font->potm->otmptSubscriptOffset.y = (pFT_MulFix(pOS2->ySubscriptYOffset, y_scale) + 32) >> 6;
-    font->potm->otmptSuperscriptSize.x = (pFT_MulFix(pOS2->ySuperscriptXSize, x_scale) + 32) >> 6;
-    font->potm->otmptSuperscriptSize.y = (pFT_MulFix(pOS2->ySuperscriptYSize, y_scale) + 32) >> 6;
-    font->potm->otmptSuperscriptOffset.x = (pFT_MulFix(pOS2->ySuperscriptXOffset, x_scale) + 32) >> 6;
-    font->potm->otmptSuperscriptOffset.y = (pFT_MulFix(pOS2->ySuperscriptYOffset, y_scale) + 32) >> 6;
-    font->potm->otmsStrikeoutSize = (pFT_MulFix(pOS2->yStrikeoutSize, y_scale) + 32) >> 6;
-    font->potm->otmsStrikeoutPosition = (pFT_MulFix(pOS2->yStrikeoutPosition, y_scale) + 32) >> 6;
-    if(!pPost) {
-        font->potm->otmsUnderscoreSize = 0;
-	font->potm->otmsUnderscorePosition = 0;
-    } else {
-        font->potm->otmsUnderscoreSize = (pFT_MulFix(pPost->underlineThickness, y_scale) + 32) >> 6;
-	font->potm->otmsUnderscorePosition = (pFT_MulFix(pPost->underlinePosition, y_scale) + 32) >> 6;
-    }
 
     /* otmp* members should clearly have type ptrdiff_t, but M$ knows best */
     cp = (char*)font->potm + sizeof(*font->potm);
diff --git a/include/config.h.in b/include/config.h.in
index 75e5d64..7d87986 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -135,6 +135,9 @@
 /* Define to 1 if you have the <freetype/internal/sfnt.h> header file. */
 #undef HAVE_FREETYPE_INTERNAL_SFNT_H
 
+/* Define to 1 if you have the <freetype/t1tables.h> header file. */
+#undef HAVE_FREETYPE_T1TABLES_H
+
 /* Define to 1 if you have the <freetype/ttnameid.h> header file. */
 #undef HAVE_FREETYPE_TTNAMEID_H
 
-- 
1.5.3.5


--3MwIy2ne0vdjdPXF--



More information about the wine-patches mailing list