Vincent Povirk : gdiplus: Fonts in UnitWorld shouldn' t be scaled to the page unit.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Mar 23 10:03:18 CDT 2015
Module: wine
Branch: master
Commit: 137128fa50dc6e7cb69ba47d305c1b2271977605
URL: http://source.winehq.org/git/wine.git/?a=commit;h=137128fa50dc6e7cb69ba47d305c1b2271977605
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Fri Mar 20 16:04:39 2015 -0500
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);
}
More information about the wine-cvs
mailing list