[PATCH] dlls/gdi32/freetype.c: A better divide by zero fix, report bad fonts.

max at mtew.isa-geek.net max at mtew.isa-geek.net
Sun May 5 13:48:31 CDT 2013


From: Max TenEyck Woodbury <max+git at mtew.isa-geek.net>

---
 dlls/gdi32/freetype.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index c30a358..2e94d47 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -6772,11 +6772,15 @@ static BOOL get_text_metrics(GdiFont *font, LPTEXTMETRICW ptm)
     {
         if (!get_outline_text_metrics(font) && !get_bitmap_text_metrics(font)) return FALSE;
 
+       /* HACKHACK: If a font has tmHeight=0, let us know. */
+       if (!font->potm->otmTextMetrics.tmHeight) {
+           ERR("Font named '%s' has tmHeight=0, aveWidth=%d!\n", font->ft_face->family_name, font->aveWidth);
+       }
+
         /* Make sure that the font has sane width/height ratio */
-        if (font->aveWidth)
-        {
-            if ((font->aveWidth + font->potm->otmTextMetrics.tmHeight - 1) / font->potm->otmTextMetrics.tmHeight > 100)
-            {
+        if ( font->aveWidth ) {
+            if (((font->aveWidth + font->potm->otmTextMetrics.tmHeight - 1) >
+                 (font->potm->otmTextMetrics.tmHeight) * 100)) {
                 WARN("Ignoring too large font->aveWidth %d\n", font->aveWidth);
                 font->aveWidth = 0;
             }
-- 
1.7.7.6




More information about the wine-patches mailing list