usp10: Add ScriptGetCMap functionality to translate wchars to glyphs.
This commit is contained in:
parent
82818284c3
commit
4241adbfcf
|
@ -52,6 +52,8 @@ START_TEST(usp10)
|
|||
int cChars;
|
||||
int cMaxGlyphs;
|
||||
unsigned short pwOutGlyphs[256];
|
||||
unsigned short pwOutGlyphs2[256];
|
||||
unsigned short pwOutGlyphs3[256];
|
||||
unsigned short pwLogClust[256];
|
||||
SCRIPT_VISATTR psva[256];
|
||||
int pcGlyphs;
|
||||
|
@ -59,6 +61,7 @@ START_TEST(usp10)
|
|||
GOFFSET pGoffset[256];
|
||||
ABC pABC[256];
|
||||
int cnt;
|
||||
DWORD dwFlags;
|
||||
|
||||
/* We need a valid HDC to drive a lot of Script functions which requires the following *
|
||||
* to set up for the tests. */
|
||||
|
@ -170,23 +173,40 @@ START_TEST(usp10)
|
|||
pItem[0].a.fNoGlyphIndex = 1; /* say no translate */
|
||||
hr = ScriptShape(NULL, &psc, TestItem2, cChars,
|
||||
cMaxGlyphs, &pItem[0].a,
|
||||
pwOutGlyphs, pwLogClust, psva, &pcGlyphs);
|
||||
pwOutGlyphs2, pwLogClust, psva, &pcGlyphs);
|
||||
ok (hr != E_PENDING, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n",
|
||||
(unsigned int) hr);
|
||||
ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", (unsigned int) hr);
|
||||
ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
|
||||
ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
|
||||
for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs[cnt]; cnt++) {}
|
||||
for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs2[cnt]; cnt++) {}
|
||||
ok (cnt == cChars, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
|
||||
cnt, TestItem2[cnt], pwOutGlyphs[cnt]);
|
||||
cnt, TestItem2[cnt], pwOutGlyphs2[cnt]);
|
||||
if (hr ==0) {
|
||||
hr = ScriptPlace(NULL, &psc, pwOutGlyphs, pcGlyphs, psva, &pItem[0].a, piAdvance,
|
||||
hr = ScriptPlace(NULL, &psc, pwOutGlyphs2, pcGlyphs, psva, &pItem[0].a, piAdvance,
|
||||
pGoffset, pABC);
|
||||
ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", (unsigned int) hr);
|
||||
}
|
||||
}
|
||||
hr = ScriptFreeCache( &psc);
|
||||
ok (!psc, "psc is not null after ScriptFreeCache\n");
|
||||
|
||||
/* Check to make sure that SCRIPT_CACHE gets allocated ok */
|
||||
dwFlags = 0;
|
||||
hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
|
||||
ok (hr == E_PENDING, "If psc is NULL (%08x) the E_PENDING should be returned\n",
|
||||
(unsigned int) hr);
|
||||
/* Check to see if teh results are the same as those returned by ScriptShape */
|
||||
hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
|
||||
ok (hr == 0, "ScriptGetCMap should return 0 not (%08x)\n", (unsigned int) hr);
|
||||
ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
|
||||
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");
|
||||
|
||||
}
|
||||
DeleteObject(hrgn);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
|
|
|
@ -429,6 +429,10 @@ HRESULT WINAPI ScriptPlace(HDC hdc, SCRIPT_CACHE *psc, const WORD *pwGlyphs,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* ScriptGetCMap (USP10.@)
|
||||
*
|
||||
*/
|
||||
/***********************************************************************
|
||||
* ScriptGetCMap (USP10.@)
|
||||
*
|
||||
|
@ -436,8 +440,42 @@ HRESULT WINAPI ScriptPlace(HDC hdc, SCRIPT_CACHE *psc, const WORD *pwGlyphs,
|
|||
HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars,
|
||||
int cChars, DWORD dwFlags, WORD *pwOutGlyphs)
|
||||
{
|
||||
FIXME("(%p,%p,%s,%d,0x%lx,%p): stub\n", hdc, psc, debugstr_w(pwcInChars), cChars, dwFlags, pwOutGlyphs);
|
||||
return E_NOTIMPL;
|
||||
HDC phdc;
|
||||
int cnt;
|
||||
DWORD hr;
|
||||
Scriptcache *pScriptcache;
|
||||
FIXME("(%p,%p,%s,%d,0x%lx,%p): semi-stub\n", hdc, psc, debugstr_wn(pwcInChars,cChars), cChars, dwFlags, pwOutGlyphs);
|
||||
|
||||
if (!hdc && !*psc) {
|
||||
TRACE("No Script_Cache (psc) and no hdc. Ask for one. Hdc=%p, psc=%p\n", hdc, *psc);
|
||||
return E_PENDING;
|
||||
} else
|
||||
if (hdc && !*psc) {
|
||||
pScriptcache = HeapAlloc( GetProcessHeap(), 0, sizeof(Scriptcache) );
|
||||
pScriptcache->hdc = hdc;
|
||||
phdc = hdc;
|
||||
pScriptcache->HaveWidths = 0;
|
||||
*psc = pScriptcache;
|
||||
} else
|
||||
if (*psc) {
|
||||
pScriptcache = *psc;
|
||||
phdc = pScriptcache->hdc;
|
||||
}
|
||||
|
||||
TRACE("Before: ");
|
||||
for (cnt = 0; cnt < cChars; cnt++)
|
||||
TRACE("%4x",pwcInChars[cnt]);
|
||||
TRACE("\n");
|
||||
|
||||
hr = GetGlyphIndicesW(phdc, pwcInChars, cChars, pwOutGlyphs, 0);
|
||||
TRACE("After: ");
|
||||
for (cnt = 0; cnt < cChars; cnt++) {
|
||||
TRACE("%04x",pwOutGlyphs[cnt]);
|
||||
pScriptcache->GlyphToChar[pwOutGlyphs[cnt]] = pwcInChars[cnt]; /* save for ScriptPlace */
|
||||
}
|
||||
TRACE("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -454,4 +492,3 @@ HRESULT WINAPI ScriptTextOut(const HDC hdc, SCRIPT_CACHE *psc, int x, int y, UIN
|
|||
piAdvance, piJustify, pGoffset);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue