gdi32: Fix GetGlyphIndices to select properly the invalid char glyph for TrueType fonts.
This commit is contained in:
parent
6ecccdb790
commit
4094ff0256
|
@ -4068,27 +4068,34 @@ 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)
|
||||||
{
|
{
|
||||||
|
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);
|
WineEngGetTextMetrics(font, &textm);
|
||||||
default_char = textm.tmDefaultChar;
|
default_char = textm.tmDefaultChar;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pgi[i] = default_char;
|
pgi[i] = default_char;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"))
|
|
||||||
{
|
|
||||||
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);
|
hdc = GetDC(0);
|
||||||
|
|
||||||
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] == 0x001f || glyphs[4] == 0xffff /* Vista */), "GetGlyphIndices should have returned a nonexistent char not %04x\n", glyphs[4]);
|
||||||
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, "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",
|
ok(glyphs[4] == textm.tmDefaultChar, "GetGlyphIndices should have returned a %04x not %04x\n",
|
||||||
textm.tmDefaultChar, glyphs[4]);
|
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)
|
static void test_GetKerningPairs(void)
|
||||||
|
|
Loading…
Reference in New Issue