From 27eb63b0829d5d38ed4b0ed99d240db872620d09 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 12 Dec 2011 11:14:09 +0100 Subject: [PATCH] gdi32: GetCharABCWidthsFloatW must succeed with non-TrueType fonts. --- dlls/gdi32/font.c | 9 +++++++++ dlls/gdi32/freetype.c | 3 --- dlls/gdi32/tests/font.c | 14 +++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 0d308b0de7b..d2dfd449f77 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -2656,6 +2656,7 @@ BOOL WINAPI GetCharABCWidthsW( HDC hdc, UINT firstChar, UINT lastChar, PHYSDEV dev; unsigned int i; BOOL ret; + TEXTMETRICW tm; if (!dc) return FALSE; @@ -2665,6 +2666,14 @@ BOOL WINAPI GetCharABCWidthsW( HDC hdc, UINT firstChar, UINT lastChar, return FALSE; } + /* unlike GetCharABCWidthsFloatW, this one is supposed to fail on non-TrueType fonts */ + dev = GET_DC_PHYSDEV( dc, pGetTextMetrics ); + if (!dev->funcs->pGetTextMetrics( dev, &tm ) || !(tm.tmPitchAndFamily & TMPF_TRUETYPE)) + { + release_dc_ptr( dc ); + return FALSE; + } + dev = GET_DC_PHYSDEV( dc, pGetCharABCWidths ); ret = dev->funcs->pGetCharABCWidths( dev, firstChar, lastChar, abc ); if (ret) diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 3a1ae991d9d..959f4aa7558 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -6416,9 +6416,6 @@ static BOOL freetype_GetCharABCWidths( PHYSDEV dev, UINT firstChar, UINT lastCha TRACE("%p, %d, %d, %p\n", physdev->font, firstChar, lastChar, buffer); - if(!FT_IS_SCALABLE(physdev->font->ft_face)) - return FALSE; - GDI_CheckNotLock(); EnterCriticalSection( &freetype_cs ); diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 30296a5735b..cc34fed447b 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -41,6 +41,7 @@ static DWORD (WINAPI *pGdiGetCodePage)(HDC hdc); static BOOL (WINAPI *pGetCharABCWidthsI)(HDC hdc, UINT first, UINT count, LPWORD glyphs, LPABC abc); 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 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); @@ -63,6 +64,7 @@ static void init(void) pGetCharABCWidthsI = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsI"); pGetCharABCWidthsA = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsA"); pGetCharABCWidthsW = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsW"); + pGetCharABCWidthsFloatW = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsFloatW"); pGetFontUnicodeRanges = (void *)GetProcAddress(hgdi32, "GetFontUnicodeRanges"); pGetGlyphIndicesA = (void *)GetProcAddress(hgdi32, "GetGlyphIndicesA"); pGetGlyphIndicesW = (void *)GetProcAddress(hgdi32, "GetGlyphIndicesW"); @@ -936,6 +938,7 @@ static void test_GetCharABCWidths(void) LOGFONTA lf; HFONT hfont; ABC abc[1]; + ABCFLOAT abcf[1]; WORD glyphs[1]; DWORD nb; static const struct @@ -973,7 +976,7 @@ static void test_GetCharABCWidths(void) }; UINT i; - if (!pGetCharABCWidthsA || !pGetCharABCWidthsW || !pGetCharABCWidthsI) + if (!pGetCharABCWidthsA || !pGetCharABCWidthsW || !pGetCharABCWidthsFloatW || !pGetCharABCWidthsI) { win_skip("GetCharABCWidthsA/W/I not available on this platform\n"); return; @@ -1008,6 +1011,15 @@ static void test_GetCharABCWidths(void) ret = pGetCharABCWidthsW(hdc, 'a', 'a', abc); ok(!ret, "GetCharABCWidthsW should have failed\n"); + ret = pGetCharABCWidthsFloatW(NULL, 'a', 'a', abcf); + ok(!ret, "GetCharABCWidthsFloatW should have failed\n"); + + ret = pGetCharABCWidthsFloatW(hdc, 'a', 'a', NULL); + ok(!ret, "GetCharABCWidthsFloatW should have failed\n"); + + ret = pGetCharABCWidthsFloatW(hdc, 'a', 'a', abcf); + ok(ret, "GetCharABCWidthsFloatW should have succeeded\n"); + hfont = SelectObject(hdc, hfont); DeleteObject(hfont); -- 2.11.4.GIT