Module: wine Branch: master Commit: 9288acda1db67c5cc3a80760d0dce34dd2c71cdb URL: http://source.winehq.org/git/wine.git/?a=commit;h=9288acda1db67c5cc3a80760d0...
Author: Dmitry Timoshkov dmitry@baikal.ru Date: Mon Jul 16 14:57:32 2012 +0900
gdiplus: GdipGetFontHeight should convert height from font to device units.
---
dlls/gdiplus/font.c | 23 +++++++++++++++++------ dlls/gdiplus/gdiplus.c | 24 ++++++++++++++++++++++++ dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/tests/graphics.c | 2 -- 4 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index 26cd49d..9d545e0 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -523,18 +523,29 @@ GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font, { REAL dpi; GpStatus stat; + REAL font_height;
TRACE("%p %p %p\n", font, graphics, height);
- if (graphics) + stat = GdipGetFontHeightGivenDPI(font, font->family->dpi, &font_height); + if (stat != Ok) return stat; + + if (!graphics) { - stat = GdipGetDpiY((GpGraphics*)graphics, &dpi); - if (stat != Ok) return stat; + *height = font_height; + TRACE("%s,%d => %f\n", + debugstr_w(font->family->FamilyName), font->otm.otmTextMetrics.tmHeight, *height); + return Ok; } - else - dpi = font->family->dpi;
- return GdipGetFontHeightGivenDPI(font, dpi, height); + stat = GdipGetDpiY((GpGraphics *)graphics, &dpi); + if (stat != Ok) return stat; + + *height = pixels_to_units(font_height, graphics->unit, dpi); + + TRACE("%s,%d(unit %d) => %f\n", + debugstr_w(font->family->FamilyName), font->otm.otmTextMetrics.tmHeight, graphics->unit, *height); + return Ok; }
/******************************************************************************* diff --git a/dlls/gdiplus/gdiplus.c b/dlls/gdiplus/gdiplus.c index d27924b..9b43cd6 100644 --- a/dlls/gdiplus/gdiplus.c +++ b/dlls/gdiplus/gdiplus.c @@ -366,6 +366,30 @@ REAL units_to_pixels(REAL units, GpUnit unit, REAL dpi) } }
+/* converts value in pixels to a given unit */ +REAL pixels_to_units(REAL pixels, GpUnit unit, REAL dpi) +{ + switch (unit) + { + case UnitPixel: + case UnitWorld: + case UnitDisplay: + return pixels; + case UnitPoint: + return pixels / dpi / inch_per_point; + case UnitInch: + return pixels / dpi; + break; + case UnitDocument: + return pixels * 300.0 / dpi; + case UnitMillimeter: + return pixels * mm_per_inch / dpi; + default: + FIXME("Unhandled unit type: %d\n", unit); + return 0; + } +} + /* Calculates Bezier points from cardinal spline points. */ void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1, REAL *y1, REAL *x2, REAL *y2) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index c1d19d2..5d1c685 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -50,6 +50,7 @@ extern REAL gdiplus_atan2(REAL dy, REAL dx) DECLSPEC_HIDDEN; extern GpStatus hresult_to_status(HRESULT res) DECLSPEC_HIDDEN; extern REAL convert_unit(REAL logpixels, GpUnit unit) DECLSPEC_HIDDEN; extern REAL units_to_pixels(REAL units, GpUnit unit, REAL dpi) DECLSPEC_HIDDEN; +extern REAL pixels_to_units(REAL pixels, GpUnit unit, REAL dpi) DECLSPEC_HIDDEN;
extern GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics) DECLSPEC_HIDDEN;
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index f19dd9e..b1d4616 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -3363,7 +3363,6 @@ todo_wine
status = GdipGetFontHeight(font, graphics, &rval); expect(Ok, status); -todo_wine expectf(21.726563, rval); status = GdipGetFontSize(font, &rval); expect(Ok, status); @@ -3383,7 +3382,6 @@ todo_wine
status = GdipGetFontHeight(font, graphics, &rval); expect(Ok, status); -todo_wine expectf(7.664648, rval); status = GdipGetFontSize(font, &rval); expect(Ok, status);