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

This commit is contained in:
Mikołaj Zalewski 2008-03-30 21:43:15 +02:00 committed by Alexandre Julliard
parent 6ecccdb790
commit 4094ff0256
2 changed files with 41 additions and 20 deletions

View file

@ -4068,26 +4068,33 @@ static FT_UInt get_glyph_index(const GdiFont *font, UINT glyph)
/*************************************************************
* WineEngGetGlyphIndices
*
* FIXME: add support for GGI_MARK_NONEXISTING_GLYPHS
*/
DWORD WineEngGetGlyphIndices(GdiFont *font, LPCWSTR lpstr, INT count,
LPWORD pgi, DWORD flags)
{
int i;
WCHAR default_char = 0;
TEXTMETRICW textm;
int default_char = -1;
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++)
{
pgi[i] = get_glyph_index(font, lpstr[i]);
if (pgi[i] == 0)
{
if (!default_char)
if (default_char == -1)
{
WineEngGetTextMetrics(font, &textm);
default_char = textm.tmDefaultChar;
if (FT_IS_SFNT(font->ft_face))
{
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;
}

View file

@ -583,35 +583,49 @@ static void test_GetGlyphIndices(void)
WCHAR testtext[] = {'T','e','s','t',0xffff,0};
WORD glyphs[(sizeof(testtext)/2)-1];
TEXTMETRIC textm;
HFONT hOldFont;
if (!pGetGlyphIndicesW) {
skip("GetGlyphIndices not available on platform\n");
return;
}
if(!is_font_installed("Symbol"))
{
skip("Symbol is not installed so skipping this test\n");
return;
}
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 = 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] == UNICODE_NOCHAR /* Vista */), "GetGlyphIndices should have returned a nonexistent char not %04x\n", glyphs[4]);
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",
ok(glyphs[4] == textm.tmDefaultChar, "GetGlyphIndices should have returned a %04x not %04x\n",
textm.tmDefaultChar, glyphs[4]);
if(!is_font_installed("Tahoma"))
{
skip("Tahoma is not installed so skipping this test\n");
return;
}
memset(&lf, 0, sizeof(lf));
strcpy(lf.lfFaceName, "Tahoma");
lf.lfHeight = 20;
hfont = CreateFontIndirectA(&lf);
hOldFont = SelectObject(hdc, hfont);
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] == 0xffff, "GetGlyphIndices should have returned 0xffff char not %04x\n", glyphs[4]);
flags = 0;
testtext[0] = textm.tmDefaultChar;
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %d\n", charcount);
todo_wine ok(glyphs[0] == 0, "GetGlyphIndices for tmDefaultChar should be 0 not %04x\n", glyphs[0]);
ok(glyphs[4] == 0, "GetGlyphIndices should have returned 0 not %04x\n", glyphs[4]);
DeleteObject(SelectObject(hdc, hOldFont));
}
static void test_GetKerningPairs(void)