Aric Stewart : gdi32: GetCharWidth32A/ W return positive widths for all layouts and various DC transforms.
Alexandre Julliard
julliard at winehq.org
Wed Sep 11 16:01:45 CDT 2013
Module: wine
Branch: master
Commit: 4a300d2423d18abe915ad070b9611e72749dec4d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4a300d2423d18abe915ad070b9611e72749dec4d
Author: Aric Stewart <aric at codeweavers.com>
Date: Wed Sep 11 07:46:53 2013 -0500
gdi32: GetCharWidth32A/W return positive widths for all layouts and various DC transforms.
---
dlls/gdi32/font.c | 6 ++-
dlls/gdi32/tests/font.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 113 insertions(+), 1 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index cc66000..9e516be 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -1748,9 +1748,13 @@ BOOL WINAPI GetCharWidth32W( HDC hdc, UINT firstChar, UINT lastChar,
if (ret)
{
+#define WDPTOLP(x) ((x<0)? \
+ (-abs(INTERNAL_XDSTOWS(dc, (x)))): \
+ (abs(INTERNAL_XDSTOWS(dc, (x)))))
/* convert device units to logical */
for( i = firstChar; i <= lastChar; i++, buffer++ )
- *buffer = INTERNAL_XDSTOWS(dc, *buffer);
+ *buffer = WDPTOLP(*buffer);
+#undef WDPTOLP
}
release_dc_ptr( dc );
return ret;
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 84e47ed..11299f3 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -42,6 +42,8 @@ static BOOL (WINAPI *pGetCharABCWidthsI)(HDC hdc, UINT first, UINT count, LPWOR
static BOOL (WINAPI *pGetCharABCWidthsA)(HDC hdc, UINT first, UINT last, LPABC abc);
static BOOL (WINAPI *pGetCharABCWidthsW)(HDC hdc, UINT first, UINT last, LPABC abc);
static BOOL (WINAPI *pGetCharABCWidthsFloatW)(HDC hdc, UINT first, UINT last, LPABCFLOAT abc);
+static BOOL (WINAPI *pGetCharWidth32A)(HDC hdc, UINT first, UINT last, LPINT buffer);
+static BOOL (WINAPI *pGetCharWidth32W)(HDC hdc, UINT first, UINT last, LPINT buffer);
static DWORD (WINAPI *pGetFontUnicodeRanges)(HDC hdc, LPGLYPHSET lpgs);
static DWORD (WINAPI *pGetGlyphIndicesA)(HDC hdc, LPCSTR lpstr, INT count, LPWORD pgi, DWORD flags);
static DWORD (WINAPI *pGetGlyphIndicesW)(HDC hdc, LPCWSTR lpstr, INT count, LPWORD pgi, DWORD flags);
@@ -83,6 +85,8 @@ static void init(void)
pGetCharABCWidthsA = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsA");
pGetCharABCWidthsW = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsW");
pGetCharABCWidthsFloatW = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsFloatW");
+ pGetCharWidth32A = (void *)GetProcAddress(hgdi32, "GetCharWidth32A");
+ pGetCharWidth32W = (void *)GetProcAddress(hgdi32, "GetCharWidth32W");
pGetFontUnicodeRanges = (void *)GetProcAddress(hgdi32, "GetFontUnicodeRanges");
pGetGlyphIndicesA = (void *)GetProcAddress(hgdi32, "GetGlyphIndicesA");
pGetGlyphIndicesW = (void *)GetProcAddress(hgdi32, "GetGlyphIndicesW");
@@ -5348,6 +5352,109 @@ static void test_vertical_order(void)
DeleteDC( hdc );
}
+static void test_GetCharWidth32(void)
+{
+ BOOL ret;
+ HDC hdc;
+ LOGFONTA lf;
+ HFONT hfont;
+ INT bufferA;
+ INT bufferW;
+ HWND hwnd;
+
+ if (!pGetCharWidth32A || !pGetCharWidth32W)
+ {
+ win_skip("GetCharWidth32A/W not available on this platform\n");
+ return;
+ }
+
+ memset(&lf, 0, sizeof(lf));
+ strcpy(lf.lfFaceName, "System");
+ lf.lfHeight = 20;
+
+ hfont = CreateFontIndirectA(&lf);
+ hdc = GetDC(0);
+ hfont = SelectObject(hdc, hfont);
+
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ ret = pGetCharWidth32A(hdc, 'a', 'a', &bufferA);
+ ok(ret, "GetCharWidth32A should have succeeded\n");
+ ok (bufferA == bufferW, "Widths should be the same\n");
+ ok (bufferA > 0," Width should be greater than zero\n");
+
+ hfont = SelectObject(hdc, hfont);
+ DeleteObject(hfont);
+ ReleaseDC(NULL, hdc);
+
+ memset(&lf, 0, sizeof(lf));
+ strcpy(lf.lfFaceName, "Tahoma");
+ lf.lfHeight = 20;
+
+ hfont = CreateFontIndirectA(&lf);
+ hwnd = CreateWindowEx(0, "static", "", WS_POPUP, 0,0,100,100,
+ 0, 0, 0, NULL);
+ hdc = GetDC(hwnd);
+ SetMapMode( hdc, MM_ANISOTROPIC );
+ SelectObject(hdc, hfont);
+
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ ok (bufferW > 0," Width should be greater than zero\n");
+ SetWindowExtEx(hdc, -1,-1,NULL);
+ SetGraphicsMode(hdc, GM_COMPATIBLE);
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ ok (bufferW > 0," Width should be greater than zero\n");
+ SetGraphicsMode(hdc, GM_ADVANCED);
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ todo_wine ok (bufferW > 0," Width should be greater than zero\n");
+ SetWindowExtEx(hdc, 1,1,NULL);
+ SetGraphicsMode(hdc, GM_COMPATIBLE);
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ ok (bufferW > 0," Width should be greater than zero\n");
+ SetGraphicsMode(hdc, GM_ADVANCED);
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ ok (bufferW > 0," Width should be greater than zero\n");
+
+ ReleaseDC(hwnd, hdc);
+ DestroyWindow(hwnd);
+
+ hwnd = CreateWindowEx(WS_EX_LAYOUTRTL, "static", "", WS_POPUP, 0,0,100,100,
+ 0, 0, 0, NULL);
+ hdc = GetDC(hwnd);
+ SetMapMode( hdc, MM_ANISOTROPIC );
+ SelectObject(hdc, hfont);
+
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ ok (bufferW > 0," Width should be greater than zero\n");
+ SetWindowExtEx(hdc, -1,-1,NULL);
+ SetGraphicsMode(hdc, GM_COMPATIBLE);
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ ok (bufferW > 0," Width should be greater than zero\n");
+ SetGraphicsMode(hdc, GM_ADVANCED);
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ ok (bufferW > 0," Width should be greater than zero\n");
+ SetWindowExtEx(hdc, 1,1,NULL);
+ SetGraphicsMode(hdc, GM_COMPATIBLE);
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ ok (bufferW > 0," Width should be greater than zero\n");
+ SetGraphicsMode(hdc, GM_ADVANCED);
+ ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
+ ok(ret, "GetCharWidth32W should have succeeded\n");
+ todo_wine ok (bufferW > 0," Width should be greater than zero\n");
+
+ ReleaseDC(hwnd, hdc);
+ DestroyWindow(hwnd);
+ DeleteObject(hfont);
+}
START_TEST(font)
{
@@ -5407,6 +5514,7 @@ START_TEST(font)
test_east_asian_font_selection();
test_max_height();
test_vertical_order();
+ test_GetCharWidth32();
/* These tests should be last test until RemoveFontResource
* is properly implemented.
More information about the wine-cvs
mailing list