gdiplus: Avoid saving negative values in pixel_size and emSize.

Dmitry Timoshkov dmitry at baikal.ru
Thu Apr 19 07:43:51 CDT 2012


This results from calling GdipCreateFontFromLogfont("Arial",-11,...)
with logical font height -11, and leads to various wrong calculations
later on. It should be be an obvious fix.
---
 dlls/gdiplus/font.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index 169e28f..1ac7604 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -190,9 +190,6 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
     (*font)->lfw.lfUnderline = logfont->lfUnderline;
     (*font)->lfw.lfStrikeOut = logfont->lfStrikeOut;
 
-    (*font)->pixel_size = (*font)->emSize = logfont->lfHeight;
-    (*font)->unit = UnitPixel;
-
     hfont = CreateFontIndirectW(&(*font)->lfw);
     oldfont = SelectObject(hdc, hfont);
     GetTextMetricsW(hdc, &textmet);
@@ -201,6 +198,8 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
     (*font)->lfw.lfWeight = textmet.tmWeight;
     (*font)->lfw.lfCharSet = textmet.tmCharSet;
 
+    (*font)->pixel_size = (*font)->emSize = textmet.tmHeight;
+    (*font)->unit = UnitPixel;
     (*font)->height = 1; /* FIXME: need NEWTEXTMETRIC.ntmSizeEM here */
     (*font)->line_spacing = textmet.tmAscent + textmet.tmDescent + textmet.tmExternalLeading;
 
-- 
1.7.9.4




More information about the wine-patches mailing list