Commit 9288acda authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdiplus: GdipGetFontHeight should convert height from font to device units.

parent ed8a3304
......@@ -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;
}
/*******************************************************************************
......
......@@ -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)
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment