gdi32: Prevent the underline / strikeout width getting rounded to zero.

Huw Davies huw at codeweavers.com
Tue May 19 02:58:24 CDT 2015


---
 dlls/gdi32/font.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 8f52053..40ba7e7 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -2109,6 +2109,18 @@ BOOL WINAPI ExtTextOutA( HDC hdc, INT x, INT y, UINT flags,
     return ret;
 }
 
+/***********************************************************************
+ *           get_line_width
+ *
+ * Scale the underline / strikeout line width.
+ */
+static inline int get_line_width( DC *dc, int metric_size )
+{
+    int width = abs( INTERNAL_YWSTODS( dc, metric_size ));
+    if (width == 0) width = 1;
+    if (metric_size < 0) width = -width;
+    return width;
+}
 
 /***********************************************************************
  *           ExtTextOutW    (GDI32.@)
@@ -2473,11 +2485,10 @@ done:
             GetOutlineTextMetricsW(hdc, size, otm);
             underlinePos = abs( INTERNAL_YWSTODS( dc, otm->otmsUnderscorePosition ));
             if (otm->otmsUnderscorePosition < 0) underlinePos = -underlinePos;
-            underlineWidth = abs( INTERNAL_YWSTODS( dc, otm->otmsUnderscoreSize ));
-            if (otm->otmsUnderscoreSize < 0) underlineWidth = -underlineWidth;
+            underlineWidth = get_line_width( dc, otm->otmsUnderscoreSize );
             strikeoutPos = abs( INTERNAL_YWSTODS( dc, otm->otmsStrikeoutPosition ));
             if (otm->otmsStrikeoutPosition < 0) strikeoutPos = -strikeoutPos;
-            strikeoutWidth = abs( INTERNAL_YWSTODS( dc, otm->otmsStrikeoutSize ));
+            strikeoutWidth = get_line_width( dc, otm->otmsStrikeoutSize );
             HeapFree(GetProcessHeap(), 0, otm);
         }
 
-- 
1.8.0




More information about the wine-patches mailing list