From f8b11542266e78f9ac7b7161da2474cf772860fb Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 9 Aug 2012 12:54:48 +0900 Subject: [PATCH] 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 9d545e0ac22..51fda73fa13 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 2c3239068e2..5f1213c9538 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);