From 0dc765809c602cf62a87e28451e4eea81eeca0cb Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Sat, 8 Dec 2007 22:55:01 +0100 Subject: [PATCH] gdi32: GetCharABCWidthsI does not require a scalable font. --- dlls/gdi32/font.c | 12 ++++++++++ dlls/gdi32/freetype.c | 2 +- dlls/gdi32/tests/font.c | 51 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 9fba58e9350..645ac196213 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -2510,6 +2510,12 @@ BOOL WINAPI GetCharABCWidthsW( HDC hdc, UINT firstChar, UINT lastChar, if (!dc) return FALSE; + if (!abc) + { + DC_ReleaseDCPtr( dc ); + return FALSE; + } + if(dc->gdiFont) ret = WineEngGetCharABCWidths( dc->gdiFont, firstChar, lastChar, abc ); else @@ -2559,6 +2565,12 @@ BOOL WINAPI GetCharABCWidthsI( HDC hdc, UINT firstChar, UINT count, if (!dc) return FALSE; + if (!abc) + { + DC_ReleaseDCPtr( dc ); + return FALSE; + } + if(dc->gdiFont) ret = WineEngGetCharABCWidthsI( dc->gdiFont, firstChar, count, pgi, abc ); else diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index e9fb663771a..b6a9344d6a9 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -4512,7 +4512,7 @@ BOOL WineEngGetCharABCWidthsI(GdiFont *font, UINT firstChar, UINT count, LPWORD FT_UInt glyph_index; GdiFont *linked_font; - if(!FT_IS_SCALABLE(font->ft_face)) + if(!FT_HAS_HORIZONTAL(font->ft_face)) return FALSE; get_glyph_index_linked(font, 'a', &linked_font, &glyph_index); diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 66d97b7acea..0893b87dfa2 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -33,6 +33,7 @@ #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got) LONG (WINAPI *pGdiGetCharDimensions)(HDC hdc, LPTEXTMETRICW lptm, LONG *height); +BOOL (WINAPI *pGetCharABCWidthsI)(HDC hdc, UINT first, UINT count, LPWORD glyphs, LPABC abc); BOOL (WINAPI *pGetCharABCWidthsW)(HDC hdc, UINT first, UINT last, LPABC abc); DWORD (WINAPI *pGetFontUnicodeRanges)(HDC hdc, LPGLYPHSET lpgs); DWORD (WINAPI *pGetGlyphIndicesA)(HDC hdc, LPCSTR lpstr, INT count, LPWORD pgi, DWORD flags); @@ -45,6 +46,7 @@ static void init(void) hgdi32 = GetModuleHandleA("gdi32.dll"); pGdiGetCharDimensions = (void *)GetProcAddress(hgdi32, "GdiGetCharDimensions"); + pGetCharABCWidthsI = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsI"); pGetCharABCWidthsW = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsW"); pGetFontUnicodeRanges = (void *)GetProcAddress(hgdi32, "GetFontUnicodeRanges"); pGetGlyphIndicesA = (void *)GetProcAddress(hgdi32, "GetGlyphIndicesA"); @@ -450,14 +452,55 @@ static void test_GdiGetCharDimensions(void) DeleteDC(hdc); } -static void test_GetCharABCWidthsW(void) +static void test_GetCharABCWidths(void) { + static const WCHAR str[] = {'a',0}; BOOL ret; + HDC hdc; + LOGFONTA lf; + HFONT hfont; ABC abc[1]; - if (!pGetCharABCWidthsW) return; + WORD glyphs[1]; + DWORD nb; + + if (!pGetCharABCWidthsW || !pGetCharABCWidthsI) + { + skip("GetCharABCWidthsW/I 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); + + nb = pGetGlyphIndicesW(hdc, str, 1, glyphs, 0); + ok(nb == 1, "pGetGlyphIndicesW should have returned 1\n"); + + ret = pGetCharABCWidthsI(NULL, 0, 1, glyphs, abc); + ok(!ret, "GetCharABCWidthsI should have failed\n"); + + ret = pGetCharABCWidthsI(hdc, 0, 1, glyphs, NULL); + ok(!ret, "GetCharABCWidthsI should have failed\n"); + + ret = pGetCharABCWidthsI(hdc, 0, 1, glyphs, abc); + ok(ret, "GetCharABCWidthsI should have succeeded\n"); ret = pGetCharABCWidthsW(NULL, 'a', 'a', abc); - ok(!ret, "GetCharABCWidthsW should have returned FALSE\n"); + ok(!ret, "GetCharABCWidthsW should have failed\n"); + + ret = pGetCharABCWidthsW(hdc, 'a', 'a', NULL); + ok(!ret, "GetCharABCWidthsW should have failed\n"); + + ret = pGetCharABCWidthsW(hdc, 'a', 'a', abc); + ok(!ret, "GetCharABCWidthsW should have failed\n"); + + hfont = SelectObject(hdc, hfont); + DeleteObject(hfont); + ReleaseDC(NULL, hdc); } static void test_text_extents(void) @@ -1702,7 +1745,7 @@ START_TEST(font) test_bitmap_font(); test_bitmap_font_metrics(); test_GdiGetCharDimensions(); - test_GetCharABCWidthsW(); + test_GetCharABCWidths(); test_text_extents(); test_GetGlyphIndices(); test_GetKerningPairs();