Commit abae85b9 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

usp10: Fix ScriptGetCMap handling of unsupported glyphs.

parent 6478e41b
......@@ -583,10 +583,12 @@ static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
int cInChars;
int cChars;
unsigned short pwOutGlyphs3[256];
WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
DWORD dwFlags;
int cnt;
static const WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
static const WCHAR TestItem2[] = {0x202B, 'i', 'n', 0x202C,0};
/* Check to make sure that SCRIPT_CACHE gets allocated ok */
dwFlags = 0;
cInChars = cChars = 5;
......@@ -627,10 +629,19 @@ static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
for (cnt=0; cnt < cChars && pwOutGlyphs[cnt] == pwOutGlyphs3[cnt]; cnt++) {}
ok (cnt == cInChars, "Translation not correct. WCHAR %d - %04x != %04x\n",
cnt, pwOutGlyphs[cnt], pwOutGlyphs3[cnt]);
hr = ScriptFreeCache( &psc);
ok (!psc, "psc is not null after ScriptFreeCache\n");
cInChars = cChars = 4;
hr = ScriptGetCMap(hdc, &psc, TestItem2, cInChars, dwFlags, pwOutGlyphs3);
ok (hr == S_FALSE, "ScriptGetCMap should return S_FALSE not (%08x)\n", hr);
ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
ok(pwOutGlyphs3[0] == 0, "Glyph 0 should be default glyph\n");
ok(pwOutGlyphs3[3] == 0, "Glyph 0 should be default glyph\n");
hr = ScriptFreeCache( &psc);
ok (!psc, "psc is not null after ScriptFreeCache\n");
}
static void test_ScriptGetFontProperties(HDC hdc)
......
......@@ -1528,6 +1528,8 @@ HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars
if ((hr = init_script_cache(hdc, psc)) != S_OK) return hr;
hr = S_OK;
if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE))
{
for (i = 0; i < cChars; i++)
......@@ -1537,6 +1539,11 @@ HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars
WORD glyph;
if (!hdc) return E_PENDING;
if (GetGlyphIndicesW(hdc, &pwcInChars[i], 1, &glyph, GGI_MARK_NONEXISTING_GLYPHS) == GDI_ERROR) return S_FALSE;
if (glyph == 0xffff)
{
hr = S_FALSE;
glyph = 0x0;
}
pwOutGlyphs[i] = set_cache_glyph(psc, pwcInChars[i], glyph);
}
}
......@@ -1546,7 +1553,7 @@ HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars
TRACE("no glyph translation\n");
for (i = 0; i < cChars; i++) pwOutGlyphs[i] = pwcInChars[i];
}
return S_OK;
return hr;
}
/***********************************************************************
......
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