Huw Davies : gdi32: Ignore max_extent if nfit is NULL.

Alexandre Julliard julliard at winehq.org
Mon Jul 22 14:22:46 CDT 2013


Module: wine
Branch: master
Commit: cf9cb6c11837910b646a33e09e45ec9f91434214
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cf9cb6c11837910b646a33e09e45ec9f91434214

Author: Huw Davies <huw at codeweavers.com>
Date:   Mon Jul 22 14:07:36 2013 +0100

gdi32: Ignore max_extent if nfit is NULL.

---

 dlls/gdi32/font.c       |    4 ++--
 dlls/gdi32/tests/font.c |   24 ++++++++++++++++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index c6bd65b..cc66000 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -1186,7 +1186,7 @@ BOOL WINAPI GetTextExtentExPointI( HDC hdc, const WORD *indices, INT count, INT
             for (i = 0; i < count; i++)
             {
                 unsigned int dx = abs( INTERNAL_XDSTOWS( dc, pos[i] )) + (i + 1) * dc->charExtra;
-                if (dx > (unsigned int)max_ext) break;
+                if (nfit && dx > (unsigned int)max_ext) break;
                 if (dxs) dxs[i] = dx;
             }
             if (nfit) *nfit = i;
@@ -1323,7 +1323,7 @@ BOOL WINAPI GetTextExtentExPointW( HDC hdc, LPCWSTR str, INT count, INT max_ext,
             for (i = 0; i < count; i++)
             {
                 unsigned int dx = abs( INTERNAL_XDSTOWS( dc, pos[i] )) + (i + 1) * dc->charExtra;
-                if (dx > (unsigned int)max_ext) break;
+                if (nfit && dx > (unsigned int)max_ext) break;
 		if (dxs) dxs[i] = dx;
             }
             if (nfit) *nfit = i;
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 6ee8db4..2fc7069 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -1207,7 +1207,7 @@ static void test_text_extents(void)
 {
     static const WCHAR wt[] = {'O','n','e','\n','t','w','o',' ','3',0};
     LPINT extents;
-    INT i, len, fit1, fit2;
+    INT i, len, fit1, fit2, extents2[3];
     LOGFONTA lf;
     TEXTMETRICA tm;
     HDC hdc;
@@ -1269,7 +1269,6 @@ static void test_text_extents(void)
     GetTextExtentExPointW(hdc, wt, 2, 0, NULL, NULL, &sz1);
     ok(sz1.cx == sz2.cx && sz1.cy == sz2.cy,
        "GetTextExtentExPointW with lpnFit and alpDx both NULL returns incorrect results\n");
-    HeapFree(GetProcessHeap(), 0, extents);
 
     /* extents functions fail with -ve counts (the interesting case being -1) */
     ret = GetTextExtentPointA(hdc, "o", -1, &sz);
@@ -1314,6 +1313,27 @@ static void test_text_extents(void)
 
     hfont = SelectObject(hdc, hfont);
     DeleteObject(hfont);
+
+    /* non-MM_TEXT mapping mode */
+    lf.lfHeight = 2000;
+    hfont = CreateFontIndirectA(&lf);
+    hfont = SelectObject(hdc, hfont);
+
+    SetMapMode( hdc, MM_HIMETRIC );
+    ret = GetTextExtentExPointW(hdc, wt, 3, 0, NULL, extents, &sz);
+    ok(ret, "got %d\n", ret);
+    ok(sz.cx == extents[2], "got %d vs %d\n", sz.cx, extents[2]);
+
+    ret = GetTextExtentExPointW(hdc, wt, 3, extents[1], &fit1, extents2, &sz2);
+    ok(ret, "got %d\n", ret);
+    ok(fit1 == 2, "got %d\n", fit1);
+    ok(sz2.cx == sz.cx, "got %d vs %d\n", sz2.cx, sz.cx);
+    for(i = 0; i < 2; i++)
+        ok(extents2[i] == extents[i], "%d: %d, %d\n", i, extents2[i], extents[i]);
+
+    hfont = SelectObject(hdc, hfont);
+    DeleteObject(hfont);
+    HeapFree(GetProcessHeap(), 0, extents);
     ReleaseDC(NULL, hdc);
 }
 




More information about the wine-cvs mailing list