Dmitry Timoshkov : gdiplus: GdipGetLogFontW should transform returned font height using font and device unit /resolution/scale.

Alexandre Julliard julliard at winehq.org
Tue Aug 14 12:59:53 CDT 2012


Module: wine
Branch: master
Commit: f8b11542266e78f9ac7b7161da2474cf772860fb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f8b11542266e78f9ac7b7161da2474cf772860fb

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Thu Aug  9 12:54:48 2012 +0900

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

---

 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 2c32390..5f1213c 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);
 




More information about the wine-cvs mailing list