[PATCH] gdi32: change negative values in OS2 struct to 0

Marcus Meissner meissner at suse.de
Sun Nov 12 10:51:42 CST 2017


fixes gdiplus:font testcase with Goha-Tibeb Zemen font.

Signed-off-by: Marcus Meissner <meissner at suse.de>
---
 dlls/gdi32/freetype.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 346e21dc21..0e85f98169 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -7928,8 +7928,26 @@ static BOOL get_outline_text_metrics(GdiFont *font)
     font->potm->otmAscent = SCALE_Y(pOS2->sTypoAscender);
     font->potm->otmDescent = SCALE_Y(pOS2->sTypoDescender);
     font->potm->otmLineGap = SCALE_Y(pOS2->sTypoLineGap);
-    font->potm->otmsCapEmHeight = SCALE_Y(pOS2->sCapHeight);
-    font->potm->otmsXHeight = SCALE_Y(pOS2->sxHeight);
+    /* There is one font which has 0x8000 in it, which would be -32768 and not map
+     * to an unsigned integer */
+    if (pOS2->sCapHeight < 0)
+    {
+        font->potm->otmsCapEmHeight = 0;
+        WARN("%s sCapHeight=%d\n",debugstr_w(font->name), pOS2->sCapHeight);
+    }
+    else
+    {
+        font->potm->otmsCapEmHeight = SCALE_Y(pOS2->sCapHeight);
+    }
+    if (pOS2->sxHeight < 0)
+    {
+        font->potm->otmsXHeight = 0;
+        WARN("%s  sxHeight=%d\n",debugstr_w(font->name), pOS2->sxHeight);
+    }
+    else
+    {
+        font->potm->otmsXHeight = SCALE_Y(pOS2->sxHeight);
+    }
     font->potm->otmrcFontBox.left = SCALE_X(ft_face->bbox.xMin);
     font->potm->otmrcFontBox.right = SCALE_X(ft_face->bbox.xMax);
     font->potm->otmrcFontBox.top = SCALE_Y(ft_face->bbox.yMax);
-- 
2.15.0




More information about the wine-devel mailing list