user32: Don't scale draw text margin params by character width units

Ulrich Czekalla ulrich.czekalla at utoronto.ca
Mon Feb 2 12:47:00 CST 2009


Values passed in DRAWTEXTPARAMS are already in average character width
units.
---
 dlls/user32/tests/text.c |   17 +++++++++++++++++
 dlls/user32/text.c       |    4 ++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/tests/text.c b/dlls/user32/tests/text.c
index fc554ae..47f5274 100644
--- a/dlls/user32/tests/text.c
+++ b/dlls/user32/tests/text.c
@@ -316,6 +316,23 @@ static void test_DrawTextCalcRect(void)
     ok(textheight==0,"Got textheight from DrawTextExA\n");
     ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
 
+    /* Margin calculations */
+    dtp.cbSize = sizeof(dtp);
+    dtp.iLeftMargin = 0;
+    dtp.iRightMargin = 0;
+    SetRect( &rect, 0, 0, 0, 0);
+    DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
+    textlen = rect.right; /* Width without margin */
+    dtp.iLeftMargin = 8;
+    SetRect( &rect, 0, 0, 0, 0);
+    DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
+    ok(rect.right==dtp.iLeftMargin+textlen  ,"Incorrect left margin calculated  rc(%d,%d)\n", rect.left, rect.right);
+    dtp.iLeftMargin = 0;
+    dtp.iRightMargin = 8;
+    SetRect( &rect, 0, 0, 0, 0);
+    DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
+    ok(rect.right==dtp.iRightMargin+textlen  ,"Incorrect right margin calculated rc(%d,%d)\n", rect.left, rect.right);
+
     /* Wide char versions */
     SetRect( &rect, 10,10, 100, 100);
     SetLastError( 0);
diff --git a/dlls/user32/text.c b/dlls/user32/text.c
index 2b864a2..b8aad0b 100644
--- a/dlls/user32/text.c
+++ b/dlls/user32/text.c
@@ -900,8 +900,8 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
 
     if (dtp)
     {
-        lmargin = dtp->iLeftMargin * tm.tmAveCharWidth;
-        rmargin = dtp->iRightMargin * tm.tmAveCharWidth;
+        lmargin = dtp->iLeftMargin;
+        rmargin = dtp->iRightMargin;
         if (!(flags & (DT_CENTER | DT_RIGHT)))
             x += lmargin;
         dtp->uiLengthDrawn = 0;     /* This param RECEIVES number of chars processed */
-- 
1.5.6.3



More information about the wine-patches mailing list