gdiplus: Fonts in UnitWorld shouldn't be scaled to the page unit.
Vincent Povirk
madewokherd at gmail.com
Fri Mar 20 16:16:30 CDT 2015
-------------- next part --------------
From c4d72975b60bebb0495221e5b4db91387e876acb Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Fri, 20 Mar 2015 16:04:39 -0500
Subject: [PATCH] gdiplus: Fonts in UnitWorld shouldn't be scaled to the page
unit.
---
dlls/gdiplus/font.c | 2 +-
dlls/gdiplus/graphics.c | 2 +-
dlls/gdiplus/tests/graphics.c | 56 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index f485058..850f44a 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -465,7 +465,7 @@ GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics, LOGFONTW
matrix = graphics->worldtrans;
- if (font->unit == UnitPixel)
+ if (font->unit == UnitPixel || font->unit == UnitWorld)
{
height = units_to_pixels(font->emSize, graphics->unit, graphics->yres);
if (graphics->unit != UnitDisplay)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 5284b99..7485a3c 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -2123,7 +2123,7 @@ static void get_font_hfont(GpGraphics *graphics, GDIPCONST GpFont *font,
HFONT unscaled_font;
TEXTMETRICW textmet;
- if (font->unit == UnitPixel)
+ if (font->unit == UnitPixel || font->unit == UnitWorld)
font_height = font->emSize;
else
{
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 77de9e4..f237090 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -3695,6 +3695,62 @@ todo_wine
GdipDeleteFont(font);
}
+ /* Font with units = UnitWorld */
+ for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+ {
+ GpPointF pt = {0.0, 100.0};
+ GpImage* image;
+ REAL expected_width, expected_height;
+
+ graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale, &image);
+
+ status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpaceDevice, &pt, 1);
+ expect(Ok, status);
+
+ status = GdipCreateFont(family, pt.Y, FontStyleRegular, UnitWorld, &font);
+ expect(Ok, status);
+
+ status = GdipGetFontUnit(font, &font_unit);
+ expect(Ok, status);
+ expect(UnitWorld, font_unit);
+
+ lf.lfHeight = 0xdeadbeef;
+ status = GdipGetLogFontW(font, graphics, &lf);
+ expect(Ok, status);
+ ok(lf.lfHeight == -100, "%u: expected -100, got %d\n", i, lf.lfHeight);
+
+ set_rect_empty(&rc);
+ set_rect_empty(&bounds);
+ status = GdipMeasureString(graphics, string, -1, font, &rc, format, &bounds, &chars, &lines);
+ expect(Ok, status);
+
+ if (i == 0)
+ {
+ base_cx = bounds.Width;
+ base_cy = bounds.Height;
+ }
+
+ pt.X = 1.0;
+ pt.Y = 1.0;
+
+ status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpaceDevice, &pt, 1);
+ expect(Ok, status);
+
+ /* height is constant in device space, width is proportional to height in world space */
+ expected_width = base_cx * pt.Y;
+ expected_height = base_cy * pt.Y;
+
+ if (td[i].unit == UnitDisplay || td[i].unit == UnitPixel)
+ ok(fabs(expected_width - bounds.Width) <= 0.001, "%u: expected %f, got %f\n", i, expected_width, bounds.Width);
+ else
+ todo_wine ok(fabs(expected_width - bounds.Width) <= 0.001, "%u: expected %f, got %f\n", i, expected_width, bounds.Width);
+ ok(fabs(expected_height - bounds.Height) <= 0.001, "%u: expected %f, got %f\n", i, expected_height, bounds.Height);
+
+ GdipDeleteGraphics(graphics);
+ GdipDisposeImage(image);
+ GdipDeleteFont(font);
+ }
+
GdipDeleteFontFamily(family);
GdipDeleteStringFormat(format);
}
--
2.1.0
More information about the wine-patches
mailing list