Module: wine Branch: master Commit: 5c987fc57403a4ed26cd35b33318069913a66ab6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5c987fc57403a4ed26cd35b333...
Author: Kusanagi Kouichi slash@ac.auone-net.jp Date: Thu Jan 13 19:18:16 2011 +0900
gdi32: GetCharABCWidthsA should work for DBCS.
---
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,