user32: fix TabbedTextOut (fixes bug #8080)

Mikołaj Zalewski mikolaj at zalewski.pl
Wed May 2 13:56:23 CDT 2007


The TEXT_TabbedTextOut didn't set correctly the text starting point (x0) 
for left-aligned tabs and was ignoring the last tab. I've also changed 
GetTextMetricsA to W as this should be slightly faster.
-------------- next part --------------
From 38d361b171c120c6579a357f576989be3591d30a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Wed, 2 May 2007 20:30:43 +0200
Subject: [PATCH] user32: fix TabbedTextOut

---
 dlls/user32/text.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/dlls/user32/text.c b/dlls/user32/text.c
index cd1cc75..ab099fc 100644
--- a/dlls/user32/text.c
+++ b/dlls/user32/text.c
@@ -1248,8 +1248,8 @@ static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCWSTR lpstr,
     }
     else
     {
-        TEXTMETRICA tm;
-        GetTextMetricsA( hdc, &tm );
+        TEXTMETRICW tm;
+        GetTextMetricsW( hdc, &tm );
         defWidth = 8 * tm.tmAveCharWidth;
     }
 
@@ -1270,12 +1270,13 @@ static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCWSTR lpstr,
         /* and if there is a <tab>, calculate its position */
         if( i) {
             /* get x coordinate for the drawing of this string */
-            for (; cTabStops > i; lpTabPos++, cTabStops--)
+            for (; cTabStops >= i; lpTabPos++, cTabStops--)
             {
                 if( nTabOrg + abs( *lpTabPos) > x) {
                     if( lpTabPos[ i - 1] >= 0) {
                         /* a left aligned tab */
-                        x = nTabOrg + lpTabPos[ i-1] + extent.cx;
+                        x0 = nTabOrg + lpTabPos[i-1];
+                        x = x0 + extent.cx;
                         break;
                     }
                     else
@@ -1294,10 +1295,10 @@ static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCWSTR lpstr,
             }
             /* if we have run out of tab stops and we have a valid default tab
              * stop width then round x up to that width */
-            if ((cTabStops <= i) && (defWidth > 0)) {
+            if ((cTabStops < i) && (defWidth > 0)) {
                 x0 = nTabOrg + ((x - nTabOrg) / defWidth + i) * defWidth;
                 x = x0 + extent.cx;
-            } else if ((cTabStops <= i) && (defWidth < 0)) {
+            } else if ((cTabStops < i) && (defWidth < 0)) {
                 x = nTabOrg + ((x - nTabOrg + extent.cx) / -defWidth + i)
                     * -defWidth;
                 x0 = x - extent.cx;
-- 
1.4.4.2


More information about the wine-patches mailing list