[03/17] gdiplus: GdipGetLogFontW should transform returned font height using font and device unit/resolution/scale.

Dmitry Timoshkov dmitry at baikal.ru
Wed Aug 8 22:54:48 CDT 2012


---
 dlls/gdiplus/font.c           | 19 +++++++++++++++++--
 dlls/gdiplus/tests/graphics.c | 12 ------------
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index 9d545e0..51fda73 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -449,8 +449,23 @@ GpStatus WINGDIPAPI GdipGetLogFontA(GpFont *font, GpGraphics *graphics,
 
 void get_log_fontW(const GpFont *font, GpGraphics *graphics, LOGFONTW *lf)
 {
-    /* FIXME: use graphics */
-    lf->lfHeight = -units_to_pixels(font->emSize, font->unit, font->family->dpi);
+    REAL height;
+
+    if (font->unit == UnitPixel)
+    {
+        height = units_to_pixels(font->emSize, graphics->unit, graphics->yres);
+        if (graphics->unit != UnitDisplay)
+            height *= graphics->scale;
+    }
+    else
+    {
+        if (graphics->unit == UnitDisplay || graphics->unit == UnitPixel)
+            height = units_to_pixels(font->emSize, font->unit, graphics->xres);
+        else
+            height = units_to_pixels(font->emSize, font->unit, graphics->yres);
+    }
+
+    lf->lfHeight = -(height + 0.5);
     lf->lfWidth = 0;
     lf->lfEscapement = 0;
     lf->lfOrientation = 0;
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 9542df3..75e9087 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -3479,19 +3479,8 @@ static void test_GdipMeasureString(void)
         height = units_to_pixels(font_size, td[i].unit, td[i].res_y);
         if (td[i].unit != UnitDisplay)
             height *= td[i].page_scale;
-        /* FIXME: remove once Wine is fixed */
-        if (td[i].unit == UnitDisplay || (td[i].unit == UnitPixel && td[i].page_scale == 1.0))
-        ok(-lf.lfHeight == (LONG)(height + 0.5), "%u: expected %d (%f), got %d\n",
-           i, (LONG)(height + 0.5), height, lf.lfHeight);
-        else
-        {
-        todo_wine
         ok(-lf.lfHeight == (LONG)(height + 0.5), "%u: expected %d (%f), got %d\n",
            i, (LONG)(height + 0.5), height, lf.lfHeight);
-            /* further testing is useless */
-            GdipDeleteGraphics(graphics);
-            continue;
-        }
 
         height = font_size * font_to_pixel_scale;
 
@@ -3572,7 +3561,6 @@ static void test_GdipMeasureString(void)
             else
                 height = units_to_pixels(font_size, font_unit, td[i].res_y);
             /*trace("%.1f font units = %f pixels with %.1f dpi, page_scale %.1f\n", font_size, height, td[i].res_y, td[i].page_scale);*/
-todo_wine
             ok(-lf.lfHeight == (LONG)(height + 0.5), "%u: expected %d (%f), got %d\n",
                i, (LONG)(height + 0.5), height, lf.lfHeight);
 
-- 
1.7.11.4




More information about the wine-patches mailing list