Commit 22d776fc authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdi32/tests: Add some tests to show that GetGlyphIndices() should avoid best fit chars.

parent aa3e02e1
...@@ -1632,6 +1632,7 @@ static void test_GetGlyphIndices(void) ...@@ -1632,6 +1632,7 @@ static void test_GetGlyphIndices(void)
LOGFONTA lf; LOGFONTA lf;
DWORD flags = 0; DWORD flags = 0;
WCHAR testtext[] = L"Test\xffff"; WCHAR testtext[] = L"Test\xffff";
WCHAR c[] = { 0x25bc /* Black Down-Pointing Triangle */, 0x212a /* Kelvin Sign */ };
WORD glyphs[(sizeof(testtext)/2)-1]; WORD glyphs[(sizeof(testtext)/2)-1];
TEXTMETRICA textm; TEXTMETRICA textm;
HFONT hOldFont; HFONT hOldFont;
...@@ -1653,8 +1654,9 @@ static void test_GetGlyphIndices(void) ...@@ -1653,8 +1654,9 @@ static void test_GetGlyphIndices(void)
lf.lfCharSet = ANSI_CHARSET; lf.lfCharSet = ANSI_CHARSET;
hfont = CreateFontIndirectA(&lf); hfont = CreateFontIndirectA(&lf);
ok(hfont != 0, "CreateFontIndirectEx failed\n"); ok(hfont != 0, "CreateFontIndirect failed\n");
ok(GetTextMetricsA(hdc, &textm), "GetTextMetric failed\n"); hOldFont = SelectObject(hdc, hfont);
ok(GetTextMetricsA(hdc, &textm), "GetTextMetrics failed\n");
if (textm.tmCharSet == ANSI_CHARSET) if (textm.tmCharSet == ANSI_CHARSET)
{ {
flags |= GGI_MARK_NONEXISTING_GLYPHS; flags |= GGI_MARK_NONEXISTING_GLYPHS;
...@@ -1664,16 +1666,44 @@ static void test_GetGlyphIndices(void) ...@@ -1664,16 +1666,44 @@ static void test_GetGlyphIndices(void)
flags = 0; flags = 0;
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags); charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
ok(charcount == 5, "GetGlyphIndicesW count of glyphs should = 5 not %d\n", charcount); 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", ok(glyphs[4] == textm.tmDefaultChar || glyphs[4] == 0x20 /* CJK Windows */,
textm.tmDefaultChar, glyphs[4]); "GetGlyphIndicesW should have returned a %04x not %04x\n", textm.tmDefaultChar, glyphs[4]);
} }
else else
/* FIXME: Write tests for non-ANSI charsets. */ /* FIXME: Write tests for non-ANSI charsets. */
skip("GetGlyphIndices System font tests only for ANSI_CHARSET\n"); 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")) if(!is_font_installed("Tahoma"))
{ {
skip("Tahoma is not installed so skipping this test\n"); skip("Tahoma is not installed so skipping this test\n");
ReleaseDC(0, hdc);
return; return;
} }
memset(&lf, 0, sizeof(lf)); memset(&lf, 0, sizeof(lf));
...@@ -1718,12 +1748,13 @@ static void test_GetGlyphIndices(void) ...@@ -1718,12 +1748,13 @@ static void test_GetGlyphIndices(void)
ok(glyphs[4] == 0, "GetGlyphIndicesW should have returned 0 not %04x\n", glyphs[4]); ok(glyphs[4] == 0, "GetGlyphIndicesW should have returned 0 not %04x\n", glyphs[4]);
DeleteObject(SelectObject(hdc, hOldFont)); DeleteObject(SelectObject(hdc, hOldFont));
ReleaseDC(0, hdc);
ret = pRemoveFontMemResourceEx(rsrc); ret = pRemoveFontMemResourceEx(rsrc);
ok(ret, "RemoveFontMemResourceEx error %d\n", GetLastError()); ok(ret, "RemoveFontMemResourceEx error %d\n", GetLastError());
free_font(font); free_font(font);
ret = DeleteFileA(ttf_name); ret = DeleteFileA(ttf_name);
ok(ret, "Failed to delete font file, %d.\n", GetLastError()); ok(ret, "Failed to delete font file, %d.\n", GetLastError());
} }
static void test_GetKerningPairs(void) static void test_GetKerningPairs(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment