From f667c06a0cce11537005a98874ba03480b17ab54 Mon Sep 17 00:00:00 2001 From: Jeff Latimer Date: Thu, 24 Aug 2006 00:49:13 +1000 Subject: [PATCH] gdi: Add missing glyph code to GetGlyphIndices and tests. --- dlls/gdi/freetype.c | 18 ++++++++++++++++-- dlls/gdi/tests/font.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/dlls/gdi/freetype.c b/dlls/gdi/freetype.c index f82112f1239..1278b6a95c7 100644 --- a/dlls/gdi/freetype.c +++ b/dlls/gdi/freetype.c @@ -2898,11 +2898,25 @@ static FT_UInt get_glyph_index(GdiFont font, UINT glyph) DWORD WineEngGetGlyphIndices(GdiFont font, LPCWSTR lpstr, INT count, LPWORD pgi, DWORD flags) { - INT i; + int i; + WCHAR default_char = 0; + TEXTMETRICW textm; + + if (flags & GGI_MARK_NONEXISTING_GLYPHS) default_char = 0x001f; /* Indicate non existence */ for(i = 0; i < count; i++) + { pgi[i] = get_glyph_index(font, lpstr[i]); - + if (pgi[i] == 0) + { + if (!default_char) + { + WineEngGetTextMetrics(font, &textm); + default_char = textm.tmDefaultChar; + } + pgi[i] = default_char; + } + } return count; } diff --git a/dlls/gdi/tests/font.c b/dlls/gdi/tests/font.c index c4ac60d0f5c..bfda3534047 100644 --- a/dlls/gdi/tests/font.c +++ b/dlls/gdi/tests/font.c @@ -391,6 +391,36 @@ static void test_text_extents(void) ReleaseDC(NULL, hdc); } +static void test_GetGlyphIndices() +{ + HDC hdc; + HFONT hfont; + DWORD charcount; + LOGFONTA lf; + DWORD flags = 0; + WCHAR testtext[] = {'T','e','s','t',0xffff,0}; + WORD glyphs[(sizeof(testtext)/2)-1]; + TEXTMETRIC textm; + + memset(&lf, 0, sizeof(lf)); + strcpy(lf.lfFaceName, "Symbol"); + lf.lfHeight = 20; + + hfont = CreateFontIndirectA(&lf); + hdc = GetDC(0); + + ok(GetTextMetrics(hdc, &textm), "GetTextMetric failed\n"); + flags |= GGI_MARK_NONEXISTING_GLYPHS; + charcount = GetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags); + ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %ld\n", charcount); + ok(glyphs[4] == 0x001f, "GetGlyphIndices should have returned a non existant char not %04x\n", glyphs[4]); + flags = 0; + charcount = GetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags); + ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %ld\n", charcount); + ok(glyphs[4] == textm.tmDefaultChar, "GetGlyphIndices should have returned a %04x not %04x\n", + textm.tmDefaultChar, glyphs[4]); +} + START_TEST(font) { test_logfont(); @@ -399,4 +429,5 @@ START_TEST(font) test_GdiGetCharDimensions(); test_GetCharABCWidthsW(); test_text_extents(); + test_GetGlyphIndices(); }