Commit 4094ff02 authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

gdi32: Fix GetGlyphIndices to select properly the invalid char glyph for TrueType fonts.

parent 6ecccdb7
...@@ -4068,26 +4068,33 @@ static FT_UInt get_glyph_index(const GdiFont *font, UINT glyph) ...@@ -4068,26 +4068,33 @@ static FT_UInt get_glyph_index(const GdiFont *font, UINT glyph)
/************************************************************* /*************************************************************
* WineEngGetGlyphIndices * WineEngGetGlyphIndices
* *
* FIXME: add support for GGI_MARK_NONEXISTING_GLYPHS
*/ */
DWORD WineEngGetGlyphIndices(GdiFont *font, LPCWSTR lpstr, INT count, DWORD WineEngGetGlyphIndices(GdiFont *font, LPCWSTR lpstr, INT count,
LPWORD pgi, DWORD flags) LPWORD pgi, DWORD flags)
{ {
int i; int i;
WCHAR default_char = 0; int default_char = -1;
TEXTMETRICW textm;
if (flags & GGI_MARK_NONEXISTING_GLYPHS) default_char = 0x001f; /* Indicate non existence */ if (flags & GGI_MARK_NONEXISTING_GLYPHS) default_char = 0xffff; /* XP would use 0x1f for bitmap fonts */
for(i = 0; i < count; i++) for(i = 0; i < count; i++)
{ {
pgi[i] = get_glyph_index(font, lpstr[i]); pgi[i] = get_glyph_index(font, lpstr[i]);
if (pgi[i] == 0) if (pgi[i] == 0)
{ {
if (!default_char) if (default_char == -1)
{ {
WineEngGetTextMetrics(font, &textm); if (FT_IS_SFNT(font->ft_face))
default_char = textm.tmDefaultChar; {
TT_OS2 *pOS2 = pFT_Get_Sfnt_Table(font->ft_face, ft_sfnt_os2);
default_char = (pOS2->usDefaultChar ? get_glyph_index(font, pOS2->usDefaultChar) : 0);
}
else
{
TEXTMETRICW textm;
WineEngGetTextMetrics(font, &textm);
default_char = textm.tmDefaultChar;
}
} }
pgi[i] = default_char; pgi[i] = default_char;
} }
......
...@@ -583,35 +583,49 @@ static void test_GetGlyphIndices(void) ...@@ -583,35 +583,49 @@ static void test_GetGlyphIndices(void)
WCHAR testtext[] = {'T','e','s','t',0xffff,0}; WCHAR testtext[] = {'T','e','s','t',0xffff,0};
WORD glyphs[(sizeof(testtext)/2)-1]; WORD glyphs[(sizeof(testtext)/2)-1];
TEXTMETRIC textm; TEXTMETRIC textm;
HFONT hOldFont;
if (!pGetGlyphIndicesW) { if (!pGetGlyphIndicesW) {
skip("GetGlyphIndices not available on platform\n"); skip("GetGlyphIndices not available on platform\n");
return; return;
} }
if(!is_font_installed("Symbol")) hdc = GetDC(0);
ok(GetTextMetrics(hdc, &textm), "GetTextMetric failed\n");
flags |= GGI_MARK_NONEXISTING_GLYPHS;
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %d\n", charcount);
ok((glyphs[4] == 0x001f || glyphs[4] == 0xffff /* Vista */), "GetGlyphIndices should have returned a nonexistent char not %04x\n", glyphs[4]);
flags = 0;
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %d\n", charcount);
ok(glyphs[4] == textm.tmDefaultChar, "GetGlyphIndices should have returned a %04x not %04x\n",
textm.tmDefaultChar, glyphs[4]);
if(!is_font_installed("Tahoma"))
{ {
skip("Symbol is not installed so skipping this test\n"); skip("Tahoma is not installed so skipping this test\n");
return; return;
} }
memset(&lf, 0, sizeof(lf)); memset(&lf, 0, sizeof(lf));
strcpy(lf.lfFaceName, "Symbol"); strcpy(lf.lfFaceName, "Tahoma");
lf.lfHeight = 20; lf.lfHeight = 20;
hfont = CreateFontIndirectA(&lf); hfont = CreateFontIndirectA(&lf);
hdc = GetDC(0); hOldFont = SelectObject(hdc, hfont);
ok(GetTextMetrics(hdc, &textm), "GetTextMetric failed\n"); ok(GetTextMetrics(hdc, &textm), "GetTextMetric failed\n");
flags |= GGI_MARK_NONEXISTING_GLYPHS; flags |= GGI_MARK_NONEXISTING_GLYPHS;
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags); charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %d\n", charcount); ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %d\n", charcount);
ok((glyphs[4] == 0x001f || glyphs[4] == UNICODE_NOCHAR /* Vista */), "GetGlyphIndices should have returned a nonexistent char not %04x\n", glyphs[4]); ok(glyphs[4] == 0xffff, "GetGlyphIndices should have returned 0xffff char not %04x\n", glyphs[4]);
flags = 0; flags = 0;
testtext[0] = textm.tmDefaultChar;
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags); charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %d\n", charcount); ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %d\n", charcount);
ok(glyphs[4] == textm.tmDefaultChar, "GetGlyphIndices should have returned a %04x not %04x\n", todo_wine ok(glyphs[0] == 0, "GetGlyphIndices for tmDefaultChar should be 0 not %04x\n", glyphs[0]);
textm.tmDefaultChar, glyphs[4]); ok(glyphs[4] == 0, "GetGlyphIndices should have returned 0 not %04x\n", glyphs[4]);
DeleteObject(SelectObject(hdc, hOldFont));
} }
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