Module: wine Branch: master Commit: 8656f6db50d3e1a3fe30b1b700272b17fe5d8da0 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8656f6db50d3e1a3fe30b1b700...
Author: Hans Leidekker hans@codeweavers.com Date: Fri Nov 28 17:30:48 2008 +0100
gdiplus: Better implementation of GdipGetFontHeightGivenDPI.
---
dlls/gdiplus/font.c | 23 ++++++++++++++++++++++- dlls/gdiplus/gdiplus_private.h | 2 ++ 2 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index ba2f1d8..2366823 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -153,6 +153,8 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
(*font)->unit = unit; (*font)->emSize = emSize; + (*font)->height = tmw->ntmSizeEM; + (*font)->line_spacing = tmw->tmAscent + tmw->tmDescent + tmw->tmExternalLeading;
return Ok; } @@ -194,6 +196,9 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc, (*font)->lfw.lfHeight = -textmet.tmHeight; (*font)->lfw.lfWeight = textmet.tmWeight;
+ (*font)->height = 1; /* FIXME: need NEWTEXTMETRIC.ntmSizeEM here */ + (*font)->line_spacing = textmet.tmAscent + textmet.tmDescent + textmet.tmExternalLeading; + SelectObject(hdc, oldfont); DeleteObject(hfont);
@@ -444,15 +449,31 @@ GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font, */ GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height) { + REAL font_height; + TRACE("%p (%s), %f, %p\n", font, debugstr_w(font->lfw.lfFaceName), dpi, height);
if (!(font && height)) return InvalidParameter;
+ font_height = font->line_spacing * (font->emSize / font->height); + switch (font->unit) { case UnitPixel: - *height = font->emSize; + *height = font_height; + break; + case UnitPoint: + *height = font_height * dpi * inch_per_point; + break; + case UnitInch: + *height = font_height * dpi; + break; + case UnitDocument: + *height = font_height * (dpi / 300.0); + break; + case UnitMillimeter: + *height = font_height * (dpi / mm_per_inch); break; default: FIXME("Unhandled unit type: %d\n", font->unit); diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index a279268..714739c 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -209,6 +209,8 @@ struct GpImageAttributes{ struct GpFont{ LOGFONTW lfw; REAL emSize; + UINT height; + LONG line_spacing; Unit unit; };