[2/2] gdi32: GetCharABCWidthsA should work for DBCS.

Kusanagi Kouichi slash at ac.auone-net.jp
Thu Jan 13 04:18:16 CST 2011


Signed-off-by: Kusanagi Kouichi <slash at ac.auone-net.jp>
---
 dlls/gdi32/font.c       |   27 +++++++++++++++++++++------
 dlls/gdi32/tests/font.c |    1 -
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index fe68893..5d47ca6 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -2296,18 +2296,33 @@ BOOL WINAPI GetAspectRatioFilterEx( HDC hdc, LPSIZE pAspectRatio )
 BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
                                   LPABC abc )
 {
-    INT i, wlen, count = (INT)(lastChar - firstChar + 1);
+    INT i, wlen;
+    UINT c;
     LPSTR str;
     LPWSTR wstr;
     BOOL ret = TRUE;
 
-    if(count <= 0) return FALSE;
+    if (lastChar < firstChar)
+        return FALSE;
 
-    str = HeapAlloc(GetProcessHeap(), 0, count);
-    for(i = 0; i < count; i++)
-	str[i] = (BYTE)(firstChar + i);
+    str = HeapAlloc(GetProcessHeap(), 0, (lastChar - firstChar + 1) * 2 + 1);
+    if (str == NULL)
+        return FALSE;
 
-    wstr = FONT_mbtowc(hdc, str, count, &wlen, NULL);
+    for(i = 0, c = firstChar; c <= lastChar; i++, c++)
+    {
+        if (c > 0xff)
+            str[i++] = (BYTE)(c >> 8);
+        str[i] = (BYTE)c;
+    }
+    str[i] = '\0';
+
+    wstr = FONT_mbtowc(hdc, str, -1, &wlen, NULL);
+    if (wstr == NULL)
+    {
+        HeapFree(GetProcessHeap(), 0, str);
+        return FALSE;
+    }
 
     for(i = 0; i < wlen; i++)
     {
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 9b9a5b4..a8c28f4 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -973,7 +973,6 @@ static void test_GetCharABCWidths(void)
         memset(a, 0, sizeof a);
         memset(w, 0, sizeof w);
         hfont = SelectObject(hdc, hfont);
-        todo_wine
         ok(pGetCharABCWidthsA(hdc, c[i].a, c[i].a + 1, a) &&
            pGetCharABCWidthsW(hdc, c[i].w, c[i].w + 1, w) &&
            memcmp(a, w, sizeof a) == 0,
-- 
1.7.2.3




More information about the wine-patches mailing list