v2: Fix test failures under CJK Windows versions.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/gdi32/tests/font.c | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 86ccddd05e..c630b65e5e 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -1634,6 +1634,7 @@ static void test_GetGlyphIndices(void) LOGFONTA lf; DWORD flags = 0; WCHAR testtext[] = {'T','e','s','t',0xffff,0}; + WCHAR c[] = { 0x25bc /* Black Down-Pointing Triangle */, 0x212a /* Kelvin Sign */ }; WORD glyphs[(sizeof(testtext)/2)-1]; TEXTMETRICA textm; HFONT hOldFont; @@ -1655,8 +1656,9 @@ static void test_GetGlyphIndices(void) lf.lfCharSet = ANSI_CHARSET;
hfont = CreateFontIndirectA(&lf); - ok(hfont != 0, "CreateFontIndirectEx failed\n"); - ok(GetTextMetricsA(hdc, &textm), "GetTextMetric failed\n"); + ok(hfont != 0, "CreateFontIndirect failed\n"); + hOldFont = SelectObject(hdc, hfont); + ok(GetTextMetricsA(hdc, &textm), "GetTextMetrics failed\n"); if (textm.tmCharSet == ANSI_CHARSET) { flags |= GGI_MARK_NONEXISTING_GLYPHS; @@ -1666,16 +1668,44 @@ static void test_GetGlyphIndices(void) flags = 0; charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags); ok(charcount == 5, "GetGlyphIndicesW count of glyphs should = 5 not %d\n", charcount); - ok(glyphs[4] == textm.tmDefaultChar, "GetGlyphIndicesW should have returned a %04x not %04x\n", - textm.tmDefaultChar, glyphs[4]); + ok(glyphs[4] == textm.tmDefaultChar || glyphs[4] == 0x20 /* CJK Windows */, + "GetGlyphIndicesW should have returned a %04x not %04x\n", textm.tmDefaultChar, glyphs[4]); } else /* FIXME: Write tests for non-ANSI charsets. */ skip("GetGlyphIndices System font tests only for ANSI_CHARSET\n");
+ DeleteObject(SelectObject(hdc, hOldFont)); + + memset(&lf, 0, sizeof(lf)); + strcpy(lf.lfFaceName, "MS Sans Serif"); + lf.lfHeight = -13; + lf.lfCharSet = DEFAULT_CHARSET; + hfont = CreateFontIndirectA(&lf); + ok(hfont != 0, "CreateFontIndirect failed\n"); + hOldFont = SelectObject(hdc, hfont); + ok(GetTextMetricsA(hdc, &textm), "GetTextMetrics failed\n"); + + glyphs[0] = glyphs[1] = 0; + charcount = GetGlyphIndicesW(hdc, c, ARRAY_SIZE(c), glyphs, GGI_MARK_NONEXISTING_GLYPHS); + ok(charcount == ARRAY_SIZE(c), "got %u\n", charcount); + ok(glyphs[0] == 0x001f || glyphs[0] == 0xffff /* Vista */, "got %#x\n", glyphs[0]); +todo_wine + ok(glyphs[1] == 0x001f || glyphs[1] == 0xffff /* Vista */, "got %#x\n", glyphs[1]); + + glyphs[0] = glyphs[1] = 0; + charcount = GetGlyphIndicesW(hdc, c, ARRAY_SIZE(c), glyphs, 0); + ok(charcount == ARRAY_SIZE(c), "got %u\n", charcount); + ok(glyphs[0] == textm.tmDefaultChar || glyphs[0] == 0x20 /* CJK Windows */, "got %#x\n", glyphs[0]); +todo_wine + ok(glyphs[1] == textm.tmDefaultChar || glyphs[1] == 0x20 /* CJK Windows */, "got %#x\n", glyphs[1]); + + DeleteObject(SelectObject(hdc, hOldFont)); + if(!is_font_installed("Tahoma")) { skip("Tahoma is not installed so skipping this test\n"); + ReleaseDC(0, hdc); return; } memset(&lf, 0, sizeof(lf)); @@ -1720,12 +1750,13 @@ static void test_GetGlyphIndices(void) ok(glyphs[4] == 0, "GetGlyphIndicesW should have returned 0 not %04x\n", glyphs[4]); DeleteObject(SelectObject(hdc, hOldFont));
+ ReleaseDC(0, hdc); + ret = pRemoveFontMemResourceEx(rsrc); ok(ret, "RemoveFontMemResourceEx error %d\n", GetLastError()); free_font(font); ret = DeleteFileA(ttf_name); ok(ret, "Failed to delete font file, %d.\n", GetLastError()); - }
static void test_GetKerningPairs(void)