Jeff Latimer : usp10:
Add ScriptGetCMap functionality to translate wchars to glyphs.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Feb 22 10:32:11 CST 2006
Module: wine
Branch: refs/heads/master
Commit: 4241adbfcf3f6ae2b8cbdcdfe337d31b021f228d
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=4241adbfcf3f6ae2b8cbdcdfe337d31b021f228d
Author: Jeff Latimer <lats at yless4u.com.au>
Date: Wed Feb 22 23:24:52 2006 +1100
usp10: Add ScriptGetCMap functionality to translate wchars to glyphs.
---
dlls/usp10/tests/usp10.c | 28 ++++++++++++++++++++++++----
dlls/usp10/usp10.c | 43 ++++++++++++++++++++++++++++++++++++++++---
2 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
index a81af2e..12907dc 100644
--- a/dlls/usp10/tests/usp10.c
+++ b/dlls/usp10/tests/usp10.c
@@ -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);
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index 75710d9..a150274 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -433,11 +433,49 @@ HRESULT WINAPI ScriptPlace(HDC hdc, SCRI
* ScriptGetCMap (USP10.@)
*
*/
+/***********************************************************************
+ * ScriptGetCMap (USP10.@)
+ *
+ */
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 h
piAdvance, piJustify, pGoffset);
return E_NOTIMPL;
}
-
More information about the wine-cvs
mailing list