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

This commit is contained in:
Dmitry Timoshkov 2012-07-16 14:57:32 +09:00 committed by Alexandre Julliard
parent ed8a3304c4
commit 9288acda1d
4 changed files with 44 additions and 10 deletions

View File

@ -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 = GdipGetDpiY((GpGraphics*)graphics, &dpi);
if (stat != Ok) return stat;
}
else
dpi = font->family->dpi;
stat = GdipGetFontHeightGivenDPI(font, font->family->dpi, &font_height);
if (stat != Ok) return stat;
return GdipGetFontHeightGivenDPI(font, dpi, height);
if (!graphics)
{
*height = font_height;
TRACE("%s,%d => %f\n",
debugstr_w(font->family->FamilyName), font->otm.otmTextMetrics.tmHeight, *height);
return Ok;
}
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;
}
/*******************************************************************************

View File

@ -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)

View File

@ -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;

View File

@ -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);