gdiplus: Use appropriate accessors to calculate font height instead of accessing GpFont internals directly.

oldstable
Dmitry Timoshkov 2012-05-11 19:19:59 +09:00 committed by Alexandre Julliard
parent 2c93bf7e4e
commit 915cd7b5b2
1 changed files with 16 additions and 4 deletions

View File

@ -504,14 +504,26 @@ GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font,
*/
GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height)
{
REAL font_height;
GpStatus stat;
INT style;
UINT16 line_spacing, em_height;
REAL font_height, font_size;
if (!font || !height) return InvalidParameter;
TRACE("%p (%s), %f, %p\n", font,
debugstr_w(font->lfw.lfFaceName), dpi, height);
debugstr_w(font->family->FamilyName), dpi, height);
if (!(font && height)) return InvalidParameter;
stat = GdipGetFontSize((GpFont *)font, &font_size);
if (stat != Ok) return stat;
stat = GdipGetFontStyle((GpFont *)font, &style);
if (stat != Ok) return stat;
stat = GdipGetLineSpacing(font->family, style, &line_spacing);
if (stat != Ok) return stat;
stat = GdipGetEmHeight(font->family, style, &em_height);
if (stat != Ok) return stat;
font_height = font->line_spacing * (font->emSize / font->height);
font_height = (REAL)line_spacing * font_size / (REAL)em_height;
switch (font->unit)
{