[2/2] gdiplus: GdipGetFontHeight should convert height from font to device units.

Dmitry Timoshkov dmitry at baikal.ru
Tue Jul 3 03:35:18 CDT 2012


---
 dlls/gdiplus/font.c           | 43 +++++++++++++++++++++++++++++++++++++------
 dlls/gdiplus/tests/graphics.c |  2 --
 2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index f4b75ef..d9f7844 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -556,18 +556,49 @@ GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font,
 {
     REAL dpi;
     GpStatus stat;
+    REAL font_height;
 
     TRACE("%p %p %p\n", font, graphics, height);
 
-    if (graphics)
+    stat = GdipGetFontHeightGivenDPI(font, font->family->dpi, &font_height);
+    if (stat != Ok) return stat;
+
+    if (!graphics)
     {
-        stat = GdipGetDpiY((GpGraphics*)graphics, &dpi);
-        if (stat != Ok) return stat;
+        *height = font_height;
+        return Ok;
+    }
+
+    stat = GdipGetDpiY((GpGraphics *)graphics, &dpi);
+    if (stat != Ok) return stat;
+
+    switch (graphics->unit)
+    {
+        case UnitPixel:
+        case UnitWorld:
+        case UnitDisplay:
+            *height = font_height;
+            break;
+        case UnitPoint:
+            *height = font_height / (dpi * inch_per_point);
+            break;
+        case UnitInch:
+            *height = font_height / dpi;
+            break;
+        case UnitDocument:
+            *height = font_height / (dpi / 300.0);
+            break;
+        case UnitMillimeter:
+            *height = font_height / (dpi / mm_per_inch);
+            break;
+        default:
+            FIXME("Unhandled unit type: %d\n", graphics->unit);
+            return NotImplemented;
     }
-    else
-        dpi = font->family->dpi;
 
-    return GdipGetFontHeightGivenDPI(font, dpi, height);
+    TRACE("%s,%d(unit %d) => %f\n",
+          debugstr_w(font->family->FamilyName), font->otm.otmTextMetrics.tmHeight, graphics->unit, *height);
+    return Ok;
 }
 
 /*******************************************************************************
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 49139ed..8c461ff 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -3363,7 +3363,6 @@ todo_wine
 
     status = GdipGetFontHeight(font, graphics, &rval);
     expect(Ok, status);
-todo_wine
     expectf(21.726563, rval);
     status = GdipGetFontSize(font, &rval);
     expect(Ok, status);
@@ -3383,7 +3382,6 @@ todo_wine
 
     status = GdipGetFontHeight(font, graphics, &rval);
     expect(Ok, status);
-todo_wine
     expectf(7.664648, rval);
     status = GdipGetFontSize(font, &rval);
     expect(Ok, status);
-- 
1.7.11.1




More information about the wine-patches mailing list