Module: wine Branch: master Commit: f667c06a0cce11537005a98874ba03480b17ab54 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=f667c06a0cce11537005a988...
Author: Jeff Latimer lats@yless4u.com.au Date: Thu Aug 24 00:49:13 2006 +1000
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 f82112f..1278b6a 100644 --- a/dlls/gdi/freetype.c +++ b/dlls/gdi/freetype.c @@ -2898,11 +2898,25 @@ static FT_UInt get_glyph_index(GdiFont f 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 c4ac60d..bfda353 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(); }