Autosyncing with Wine HEAD

svn path=/trunk/; revision=33072
This commit is contained in:
The Wine Synchronizer 2008-04-20 17:07:15 +00:00
parent c1e47ef0a6
commit 14d17cbecf
4 changed files with 1780 additions and 1755 deletions

View file

@ -35,13 +35,6 @@
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"
DWORD STDCALL GetGlyphIndicesW( HDC hdc, LPCWSTR lpstr, int c, LPWORD pgi, DWORD fl);
BOOL STDCALL GetCharABCWidthsI(HDC hdc, UINT giFirst, UINT cgi, LPWORD pgi, LPABC lpabc);
/**
* some documentation here:
* http://www.microsoft.com/typography/developers/uniscribe/uniscribe.htm
*/
WINE_DEFAULT_DEBUG_CHANNEL(uniscribe); WINE_DEFAULT_DEBUG_CHANNEL(uniscribe);
static const SCRIPT_PROPERTIES props[] = static const SCRIPT_PROPERTIES props[] =
@ -147,8 +140,8 @@ static const SCRIPT_PROPERTIES *script_props[] =
typedef struct { typedef struct {
HDC hdc; HDC hdc;
LONG height; LOGFONTW lf;
WCHAR default_char; TEXTMETRICW tm;
} ScriptCache; } ScriptCache;
typedef struct { typedef struct {
@ -174,24 +167,24 @@ typedef struct {
SIZE* sz; SIZE* sz;
} StringAnalysis; } StringAnalysis;
static inline void *usp_alloc(SIZE_T size) static inline void *heap_alloc(SIZE_T size)
{ {
return HeapAlloc(GetProcessHeap(), 0, size); return HeapAlloc(GetProcessHeap(), 0, size);
} }
static inline void *usp_zero_alloc(SIZE_T size) static inline void *heap_alloc_zero(SIZE_T size)
{ {
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
} }
static inline void *usp_zero_realloc(LPVOID mem, SIZE_T size) static inline void *heap_realloc_zero(LPVOID mem, SIZE_T size)
{ {
return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size); return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size);
} }
static inline void usp_free(LPVOID mem) static inline BOOL heap_free(LPVOID mem)
{ {
HeapFree(GetProcessHeap(), 0, mem); return HeapFree(GetProcessHeap(), 0, mem);
} }
static HDC get_cache_hdc(SCRIPT_CACHE *psc) static HDC get_cache_hdc(SCRIPT_CACHE *psc)
@ -201,21 +194,23 @@ static HDC get_cache_hdc(SCRIPT_CACHE *psc)
static WCHAR get_cache_default_char(SCRIPT_CACHE *psc) static WCHAR get_cache_default_char(SCRIPT_CACHE *psc)
{ {
return ((ScriptCache *)*psc)->default_char; return ((ScriptCache *)*psc)->tm.tmDefaultChar;
} }
static LONG get_cache_height(SCRIPT_CACHE *psc) static LONG get_cache_height(SCRIPT_CACHE *psc)
{ {
return ((ScriptCache *)*psc)->height; return ((ScriptCache *)*psc)->tm.tmHeight;
}
static BYTE get_cache_pitch_family(SCRIPT_CACHE *psc)
{
return ((ScriptCache *)*psc)->tm.tmPitchAndFamily;
} }
static HRESULT init_script_cache(const HDC hdc, ScriptCache *sc) static HRESULT init_script_cache(const HDC hdc, ScriptCache *sc)
{ {
TEXTMETRICW metric; if (!GetTextMetricsW(hdc, &sc->tm)) return E_INVALIDARG;
if (!GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(LOGFONTW), &sc->lf)) return E_INVALIDARG;
if (!GetTextMetricsW(hdc, &metric)) return E_INVALIDARG;
sc->height = metric.tmHeight;
sc->default_char = metric.tmDefaultChar;
sc->hdc = hdc; sc->hdc = hdc;
return S_OK; return S_OK;
} }
@ -229,10 +224,10 @@ static HRESULT get_script_cache(const HDC hdc, SCRIPT_CACHE *psc)
ScriptCache *sc; ScriptCache *sc;
if (!hdc) return E_PENDING; if (!hdc) return E_PENDING;
if (!(sc = usp_zero_alloc(sizeof(ScriptCache)))) return E_OUTOFMEMORY; if (!(sc = heap_alloc_zero(sizeof(ScriptCache)))) return E_OUTOFMEMORY;
if ((ret = init_script_cache(hdc, sc))) if ((ret = init_script_cache(hdc, sc)))
{ {
usp_free(sc); heap_free(sc);
return ret; return ret;
} }
*psc = sc; *psc = sc;
@ -241,6 +236,21 @@ static HRESULT get_script_cache(const HDC hdc, SCRIPT_CACHE *psc)
return S_OK; return S_OK;
} }
static HFONT select_cached_font(SCRIPT_CACHE *psc)
{
HFONT old_font;
ScriptCache *sc = *psc;
old_font = SelectObject(sc->hdc, CreateFontIndirectW(&sc->lf));
return old_font;
}
static void unselect_cached_font(SCRIPT_CACHE *psc, HFONT old_font)
{
ScriptCache *sc = *psc;
DeleteObject(SelectObject(sc->hdc, old_font));
}
/*********************************************************************** /***********************************************************************
* DllMain * DllMain
* *
@ -276,7 +286,7 @@ HRESULT WINAPI ScriptFreeCache(SCRIPT_CACHE *psc)
if (psc) if (psc)
{ {
usp_free(*psc); heap_free(*psc);
*psc = NULL; *psc = NULL;
} }
return S_OK; return S_OK;
@ -559,7 +569,7 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
TRACE("index=%d cnt=%d iCharPos=%d\n", index+1, cnt, pItems[index+1].iCharPos = cnt); TRACE("index=%d cnt=%d iCharPos=%d\n", index+1, cnt, pItems[index+1].iCharPos = cnt);
/* Set one SCRIPT_STATE item being returned */ /* Set one SCRIPT_STATE item being returned */
*pcItems = index + 1; if (pcItems) *pcItems = index + 1;
/* Set SCRIPT_ITEM */ /* Set SCRIPT_ITEM */
pItems[index+1].iCharPos = cnt; /* the last + 1 item pItems[index+1].iCharPos = cnt; /* the last + 1 item
@ -594,8 +604,8 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
if (cString < 1 || !pString) return E_INVALIDARG; if (cString < 1 || !pString) return E_INVALIDARG;
if ((dwFlags & SSA_GLYPHS) && !hdc) return E_PENDING; if ((dwFlags & SSA_GLYPHS) && !hdc) return E_PENDING;
if (!(analysis = usp_zero_alloc(sizeof(StringAnalysis)))) return E_OUTOFMEMORY; if (!(analysis = heap_alloc_zero(sizeof(StringAnalysis)))) return E_OUTOFMEMORY;
if (!(analysis->pItem = usp_zero_alloc(num_items * sizeof(SCRIPT_ITEM) + 1))) goto error; if (!(analysis->pItem = heap_alloc_zero(num_items * sizeof(SCRIPT_ITEM) + 1))) goto error;
/* FIXME: handle clipping */ /* FIXME: handle clipping */
analysis->clip_len = cString; analysis->clip_len = cString;
@ -608,7 +618,7 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
SCRIPT_ITEM *tmp; SCRIPT_ITEM *tmp;
num_items *= 2; num_items *= 2;
if (!(tmp = usp_zero_realloc(analysis->pItem, num_items * sizeof(SCRIPT_ITEM) + 1))) if (!(tmp = heap_realloc_zero(analysis->pItem, num_items * sizeof(SCRIPT_ITEM) + 1)))
goto error; goto error;
analysis->pItem = tmp; analysis->pItem = tmp;
@ -617,12 +627,12 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
} }
if (hr) goto error; if (hr) goto error;
if ((analysis->logattrs = usp_alloc(sizeof(SCRIPT_LOGATTR) * cString))) if ((analysis->logattrs = heap_alloc(sizeof(SCRIPT_LOGATTR) * cString)))
ScriptBreak(pString, cString, (SCRIPT_STRING_ANALYSIS)analysis, analysis->logattrs); ScriptBreak(pString, cString, (SCRIPT_STRING_ANALYSIS)analysis, analysis->logattrs);
else else
goto error; goto error;
if (!(analysis->glyphs = usp_zero_alloc(sizeof(StringGlyphs) * analysis->numItems))) if (!(analysis->glyphs = heap_alloc_zero(sizeof(StringGlyphs) * analysis->numItems)))
goto error; goto error;
for (i = 0; i < analysis->numItems; i++) for (i = 0; i < analysis->numItems; i++)
@ -630,12 +640,12 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
SCRIPT_CACHE *sc = (SCRIPT_CACHE *)&analysis->sc; SCRIPT_CACHE *sc = (SCRIPT_CACHE *)&analysis->sc;
int cChar = analysis->pItem[i+1].iCharPos - analysis->pItem[i].iCharPos; int cChar = analysis->pItem[i+1].iCharPos - analysis->pItem[i].iCharPos;
int numGlyphs = 1.5 * cChar + 16; int numGlyphs = 1.5 * cChar + 16;
WORD *glyphs = usp_zero_alloc(sizeof(WORD) * numGlyphs); WORD *glyphs = heap_alloc_zero(sizeof(WORD) * numGlyphs);
WORD *pwLogClust = usp_zero_alloc(sizeof(WORD) * cChar); WORD *pwLogClust = heap_alloc_zero(sizeof(WORD) * cChar);
int *piAdvance = usp_zero_alloc(sizeof(int) * numGlyphs); int *piAdvance = heap_alloc_zero(sizeof(int) * numGlyphs);
SCRIPT_VISATTR *psva = usp_zero_alloc(sizeof(SCRIPT_VISATTR) * cChar); SCRIPT_VISATTR *psva = heap_alloc_zero(sizeof(SCRIPT_VISATTR) * cChar);
GOFFSET *pGoffset = usp_zero_alloc(sizeof(GOFFSET) * numGlyphs); GOFFSET *pGoffset = heap_alloc_zero(sizeof(GOFFSET) * numGlyphs);
ABC *abc = usp_zero_alloc(sizeof(ABC)); ABC *abc = heap_alloc_zero(sizeof(ABC));
int numGlyphsReturned; int numGlyphsReturned;
/* FIXME: non unicode strings */ /* FIXME: non unicode strings */
@ -659,10 +669,11 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
return S_OK; return S_OK;
error: error:
usp_free(analysis->glyphs); heap_free(analysis->glyphs);
usp_free(analysis->logattrs); heap_free(analysis->logattrs);
usp_free(analysis->pItem); heap_free(analysis->pItem);
usp_free(analysis); heap_free(analysis->sc);
heap_free(analysis);
return hr; return hr;
} }
@ -714,7 +725,7 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa,
{ {
cnt += analysis->glyphs[item].numGlyphs; cnt += analysis->glyphs[item].numGlyphs;
} }
if (!(glyphs = usp_alloc(sizeof(WCHAR) * cnt))) return E_OUTOFMEMORY; if (!(glyphs = heap_alloc(sizeof(WCHAR) * cnt))) return E_OUTOFMEMORY;
/* /*
* ScriptStringOut only processes glyphs hence set ETO_GLYPH_INDEX * ScriptStringOut only processes glyphs hence set ETO_GLYPH_INDEX
@ -750,7 +761,7 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa,
/* /*
* Free the output buffer and script cache * Free the output buffer and script cache
*/ */
usp_free(glyphs); heap_free(glyphs);
return hr; return hr;
} }
@ -877,19 +888,20 @@ HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
for (i = 0; i < analysis->numItems; i++) for (i = 0; i < analysis->numItems; i++)
{ {
usp_free(analysis->glyphs[i].glyphs); heap_free(analysis->glyphs[i].glyphs);
usp_free(analysis->glyphs[i].pwLogClust); heap_free(analysis->glyphs[i].pwLogClust);
usp_free(analysis->glyphs[i].piAdvance); heap_free(analysis->glyphs[i].piAdvance);
usp_free(analysis->glyphs[i].psva); heap_free(analysis->glyphs[i].psva);
usp_free(analysis->glyphs[i].pGoffset); heap_free(analysis->glyphs[i].pGoffset);
usp_free(analysis->glyphs[i].abc); heap_free(analysis->glyphs[i].abc);
} }
usp_free(analysis->glyphs); heap_free(analysis->glyphs);
usp_free(analysis->pItem); heap_free(analysis->pItem);
usp_free(analysis->logattrs); heap_free(analysis->logattrs);
usp_free(analysis->sz); heap_free(analysis->sz);
usp_free(analysis); heap_free(analysis->sc);
heap_free(analysis);
if (invalid) return E_INVALIDARG; if (invalid) return E_INVALIDARG;
return S_OK; return S_OK;
@ -1211,7 +1223,7 @@ HRESULT WINAPI ScriptIsComplex(const WCHAR *chars, int len, DWORD flag)
* pwcChars [I] Array of characters specifying the run. * pwcChars [I] Array of characters specifying the run.
* cChars [I] Number of characters in pwcChars. * cChars [I] Number of characters in pwcChars.
* cMaxGlyphs [I] Length of pwOutGlyphs. * cMaxGlyphs [I] Length of pwOutGlyphs.
* psa [I/O] String analysis. * psa [I/O] Script analysis.
* pwOutGlyphs [O] Array of glyphs. * pwOutGlyphs [O] Array of glyphs.
* pwLogClust [O] Array of logical cluster info. * pwLogClust [O] Array of logical cluster info.
* psva [O] Array of visual attributes. * psva [O] Array of visual attributes.
@ -1228,48 +1240,45 @@ HRESULT WINAPI ScriptShape(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcChars,
{ {
int cnt; int cnt;
HRESULT hr; HRESULT hr;
*pcGlyphs = cChars; HFONT hfont;
TRACE("(%p, %p, %p, %d, %d, %p)\n", hdc, psc, pwcChars, cChars, cMaxGlyphs, psa); TRACE("(%p, %p, %p, %d, %d, %p)\n", hdc, psc, pwcChars, cChars, cMaxGlyphs, psa);
if (psa) TRACE("psa values: %d, %d, %d, %d, %d, %d, %d\n", psa->eScript, psa->fRTL, psa->fLayoutRTL, if (psa) TRACE("psa values: %d, %d, %d, %d, %d, %d, %d\n", psa->eScript, psa->fRTL, psa->fLayoutRTL,
psa->fLinkBefore, psa->fLinkAfter, psa->fLogicalOrder, psa->fNoGlyphIndex); psa->fLinkBefore, psa->fLinkAfter, psa->fLogicalOrder, psa->fNoGlyphIndex);
if (!psva || !pcGlyphs) return E_INVALIDARG;
if (cChars > cMaxGlyphs) return E_OUTOFMEMORY; if (cChars > cMaxGlyphs) return E_OUTOFMEMORY;
if ((hr = get_script_cache(hdc, psc))) return hr; if ((hr = get_script_cache(hdc, psc))) return hr;
TRACE("Before: "); *pcGlyphs = cChars;
hfont = select_cached_font(psc);
if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE) && !psa->fNoGlyphIndex)
{
GetGlyphIndicesW(get_cache_hdc(psc), pwcChars, cChars, pwOutGlyphs, 0);
}
else
{
TRACE("no glyph translation\n");
for (cnt = 0; cnt < cChars; cnt++) pwOutGlyphs[cnt] = pwcChars[cnt];
}
if (psva)
{
/* set up a valid SCRIPT_VISATTR and LogClust for each char in this run */
for (cnt = 0; cnt < cChars; cnt++) for (cnt = 0; cnt < cChars; cnt++)
TRACE("%4x",pwcChars[cnt]); {
TRACE("\n");
if (!psa->fNoGlyphIndex) { /* Glyph translate */
if (!(GetGlyphIndicesW((HDC)get_cache_hdc(psc), (LPCWSTR) pwcChars, (int)cChars, (LPWORD) pwOutGlyphs,(DWORD) 0)))
return S_FALSE;
TRACE("After: ");
for (cnt = 0; cnt < cChars; cnt++) {
TRACE("%04x",pwOutGlyphs[cnt]);
}
TRACE("\n");
}
else {
TRACE("After: ");
for (cnt = 0; cnt < cChars; cnt++) { /* no translate so set up */
pwOutGlyphs[cnt] = pwcChars[cnt]; /* copy in to out and */
TRACE("%04x",pwOutGlyphs[cnt]);
}
TRACE("\n");
}
/* Set up a valid SCRIPT_VISATTR and LogClust for each char in this run */
for (cnt = 0; cnt < cChars; cnt++) {
/* FIXME: set to better values */ /* FIXME: set to better values */
psva[cnt].uJustification = 2; psva[cnt].uJustification = 2;
psva[cnt].fClusterStart = 1; psva[cnt].fClusterStart = 1;
psva[cnt].fDiacritic = 0; psva[cnt].fDiacritic = 0;
psva[cnt].fZeroWidth = 0; psva[cnt].fZeroWidth = 0;
pwLogClust[cnt] = cnt;
if (pwLogClust) pwLogClust[cnt] = cnt;
} }
}
unselect_cached_font(psc, hfont);
return S_OK; return S_OK;
} }
@ -1297,52 +1306,59 @@ HRESULT WINAPI ScriptPlace(HDC hdc, SCRIPT_CACHE *psc, const WORD *pwGlyphs,
int cGlyphs, const SCRIPT_VISATTR *psva, int cGlyphs, const SCRIPT_VISATTR *psva,
SCRIPT_ANALYSIS *psa, int *piAdvance, GOFFSET *pGoffset, ABC *pABC ) SCRIPT_ANALYSIS *psa, int *piAdvance, GOFFSET *pGoffset, ABC *pABC )
{ {
int wcnt;
HRESULT hr; HRESULT hr;
LPABC lpABC; LPABC lpABC;
HFONT hfont;
unsigned int i;
TRACE("(%p, %p, %p, %s, %d, %p, %p, %p)\n", hdc, psc, pwGlyphs, TRACE("(%p, %p, %p, %s, %d, %p, %p, %p)\n", hdc, psc, pwGlyphs,
debugstr_wn(pwGlyphs, cGlyphs), cGlyphs, psva, psa, piAdvance); debugstr_wn(pwGlyphs, cGlyphs), cGlyphs, psva, psa, piAdvance);
if (!psva) return E_INVALIDARG;
if ((hr = get_script_cache(hdc, psc))) return hr; if ((hr = get_script_cache(hdc, psc))) return hr;
hfont = select_cached_font(psc);
/* Here we need to calculate the width of the run unit. At this point the input string /* Here we need to calculate the width of the run unit. At this point the input string
* has been converted to glyphs and we still need to translate back to the original chars * has been converted to glyphs and we still need to translate back to the original chars
* to get the correct ABC widths. */ * to get the correct ABC widths. */
if (!(lpABC = usp_zero_alloc(sizeof(ABC) * cGlyphs))) return E_OUTOFMEMORY; if (!(lpABC = heap_alloc_zero(sizeof(ABC) * cGlyphs))) return E_OUTOFMEMORY;
if (pABC) memset(pABC, 0, sizeof(ABC));
memset(pABC, 0, sizeof(ABC)); if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE) && !psa->fNoGlyphIndex)
/* FIXME: set pGoffset to more reasonable values */
if (!GetCharABCWidthsI(get_cache_hdc(psc), 0, cGlyphs, (WORD *) pwGlyphs, lpABC ))
{ {
WARN("Could not get ABC values\n"); GetCharABCWidthsI(get_cache_hdc(psc), 0, cGlyphs, (WORD *)pwGlyphs, lpABC);
for (wcnt = 0; wcnt < cGlyphs; wcnt++) {
piAdvance[wcnt] = 0;
pGoffset[wcnt].du = 0;
pGoffset[wcnt].dv = 0;
}
} }
else else
{ {
for (wcnt = 0; wcnt < cGlyphs ; wcnt++) { /* add up the char lengths */ INT width;
TRACE(" Glyph=%04x, abcA=%d, abcB=%d, abcC=%d wcnt=%d\n", for (i = 0; i < cGlyphs; i++)
pwGlyphs[wcnt], {
lpABC[wcnt].abcA, GetCharWidth32W(get_cache_hdc(psc), pwGlyphs[i], pwGlyphs[i], &width);
lpABC[wcnt].abcB, lpABC[i].abcB = width;
lpABC[wcnt].abcC, wcnt);
pABC->abcA += lpABC[wcnt].abcA;
pABC->abcB += lpABC[wcnt].abcB;
pABC->abcC += lpABC[wcnt].abcC;
piAdvance[wcnt] = lpABC[wcnt].abcA + lpABC[wcnt].abcB + lpABC[wcnt].abcC;
pGoffset[wcnt].du = 0;
pGoffset[wcnt].dv = 0;
} }
} }
TRACE("Total for run: abcA=%d, abcB=%d, abcC=%d\n", pABC->abcA, pABC->abcB, pABC->abcC);
usp_free(lpABC); for (i = 0; i < cGlyphs; i++)
{
TRACE(" Glyph=%04x, abcA=%d, abcB=%d, abcC=%d index=%d\n",
pwGlyphs[i], lpABC[i].abcA, lpABC[i].abcB, lpABC[i].abcC, i);
if (pABC)
{
pABC->abcA += lpABC[i].abcA;
pABC->abcB += lpABC[i].abcB;
pABC->abcC += lpABC[i].abcC;
}
/* FIXME: set to more reasonable values */
if (pGoffset) pGoffset[i].du = pGoffset[i].dv = 0;
if (piAdvance) piAdvance[i] = lpABC[i].abcA + lpABC[i].abcB + lpABC[i].abcC;
}
if (pABC) TRACE("Total for run: abcA=%d, abcB=%d, abcC=%d\n", pABC->abcA, pABC->abcB, pABC->abcC);
heap_free(lpABC);
unselect_cached_font(psc, hfont);
return S_OK; return S_OK;
} }
@ -1366,28 +1382,20 @@ HRESULT WINAPI ScriptPlace(HDC hdc, SCRIPT_CACHE *psc, const WORD *pwGlyphs,
HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars, HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars,
int cChars, DWORD dwFlags, WORD *pwOutGlyphs) int cChars, DWORD dwFlags, WORD *pwOutGlyphs)
{ {
int cnt;
HRESULT hr; HRESULT hr;
HFONT hfont;
TRACE("(%p,%p,%s,%d,0x%x,%p)\n", hdc, psc, debugstr_wn(pwcInChars, cChars), TRACE("(%p,%p,%s,%d,0x%x,%p)\n", hdc, psc, debugstr_wn(pwcInChars, cChars),
cChars, dwFlags, pwOutGlyphs); cChars, dwFlags, pwOutGlyphs);
if ((hr = get_script_cache(hdc, psc))) return hr; if ((hr = get_script_cache(hdc, psc))) return hr;
TRACE("Before: "); hfont = select_cached_font(psc);
for (cnt = 0; cnt < cChars; cnt++) if (GetGlyphIndicesW(get_cache_hdc(psc), pwcInChars, cChars, pwOutGlyphs, 0) == GDI_ERROR)
TRACE("%4x",pwcInChars[cnt]); hr = S_FALSE;
TRACE("\n");
GetGlyphIndicesW(get_cache_hdc(psc), pwcInChars, cChars, pwOutGlyphs, 0); unselect_cached_font(psc, hfont);
return hr;
TRACE("After: ");
for (cnt = 0; cnt < cChars; cnt++) {
TRACE("%04x",pwOutGlyphs[cnt]);
}
TRACE("\n");
return S_OK;
} }
/*********************************************************************** /***********************************************************************
@ -1399,7 +1407,8 @@ HRESULT WINAPI ScriptTextOut(const HDC hdc, SCRIPT_CACHE *psc, int x, int y, UIN
int iReserved, const WORD *pwGlyphs, int cGlyphs, const int *piAdvance, int iReserved, const WORD *pwGlyphs, int cGlyphs, const int *piAdvance,
const int *piJustify, const GOFFSET *pGoffset) const int *piJustify, const GOFFSET *pGoffset)
{ {
HRESULT hr; HFONT hfont;
HRESULT hr = S_OK;
TRACE("(%p, %p, %d, %d, %04x, %p, %p, %p, %d, %p, %d, %p, %p, %p)\n", TRACE("(%p, %p, %d, %d, %04x, %p, %p, %p, %d, %p, %d, %p, %p, %p)\n",
hdc, psc, x, y, fuOptions, lprc, psa, pwcReserved, iReserved, pwGlyphs, cGlyphs, hdc, psc, x, y, fuOptions, lprc, psa, pwcReserved, iReserved, pwGlyphs, cGlyphs,
@ -1409,14 +1418,17 @@ HRESULT WINAPI ScriptTextOut(const HDC hdc, SCRIPT_CACHE *psc, int x, int y, UIN
if (!piAdvance || !psa || !pwGlyphs) return E_INVALIDARG; if (!piAdvance || !psa || !pwGlyphs) return E_INVALIDARG;
if ((hr = get_script_cache(hdc, psc))) return hr; if ((hr = get_script_cache(hdc, psc))) return hr;
hfont = select_cached_font(psc);
fuOptions &= ETO_CLIPPED + ETO_OPAQUE; fuOptions &= ETO_CLIPPED + ETO_OPAQUE;
if (!psa->fNoGlyphIndex) /* Have Glyphs? */ if (!psa->fNoGlyphIndex) /* Have Glyphs? */
fuOptions |= ETO_GLYPH_INDEX; /* Say don't do translation to glyph */ fuOptions |= ETO_GLYPH_INDEX; /* Say don't do translation to glyph */
if (!ExtTextOutW(get_cache_hdc(psc), x, y, fuOptions, lprc, pwGlyphs, cGlyphs, NULL)) if (!ExtTextOutW(get_cache_hdc(psc), x, y, fuOptions, lprc, pwGlyphs, cGlyphs, NULL))
return S_FALSE; hr = S_FALSE;
return S_OK; unselect_cached_font(psc, hfont);
return hr;
} }
/*********************************************************************** /***********************************************************************
@ -1463,15 +1475,18 @@ HRESULT WINAPI ScriptCacheGetHeight(HDC hdc, SCRIPT_CACHE *psc, LONG *height)
*/ */
HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, ABC *abc) HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, ABC *abc)
{ {
HRESULT hr; HFONT hfont;
HRESULT hr = S_OK;
TRACE("(%p, %p, 0x%04x, %p)\n", hdc, psc, glyph, abc); TRACE("(%p, %p, 0x%04x, %p)\n", hdc, psc, glyph, abc);
if ((hr = get_script_cache(hdc, psc))) return hr; if ((hr = get_script_cache(hdc, psc))) return hr;
/* FIXME: get this from the cache */ hfont = select_cached_font(psc);
if (!GetCharABCWidthsW(get_cache_hdc(psc), glyph, glyph, abc)) return E_HANDLE; if (!GetCharABCWidthsI(get_cache_hdc(psc), 0, 1, &glyph, abc)) hr = E_HANDLE;
return S_OK;
unselect_cached_font(psc, hfont);
return hr;
} }
/*********************************************************************** /***********************************************************************
@ -1600,8 +1615,8 @@ const SIZE * WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
if (!analysis->sz) if (!analysis->sz)
{ {
if (!(analysis->sz = usp_alloc(sizeof(SIZE)))) return NULL; if (!(analysis->sz = heap_alloc(sizeof(SIZE)))) return NULL;
analysis->sz->cy = analysis->sc->height; analysis->sz->cy = analysis->sc->tm.tmHeight;
analysis->sz->cx = 0; analysis->sz->cx = 0;
for (i = 0; i < analysis->numItems; i++) for (i = 0; i < analysis->numItems; i++)
@ -1684,3 +1699,35 @@ HRESULT WINAPI ScriptStringGetOrder(SCRIPT_STRING_ANALYSIS ssa, UINT *order)
return S_OK; return S_OK;
} }
/***********************************************************************
* ScriptGetLogicalWidths (USP10.@)
*
* Convert advance widths to logical widths.
*
* PARAMS
* sa [I] Script analysis.
* nbchars [I] Number of characters.
* nbglyphs [I] Number of glyphs.
* glyph_width [I] Array of glyph widths.
* log_clust [I] Array of logical clusters.
* sva [I] Visual attributes.
* widths [O] Array of logical widths.
*
* RETURNS
* Success: S_OK
* Failure: a non-zero HRESULT.
*/
HRESULT WINAPI ScriptGetLogicalWidths(const SCRIPT_ANALYSIS *sa, int nbchars, int nbglyphs,
const int *glyph_width, const WORD *log_clust,
const SCRIPT_VISATTR *sva, int *widths)
{
int i;
TRACE("(%p, %d, %d, %p, %p, %p, %p)\n",
sa, nbchars, nbglyphs, glyph_width, log_clust, sva, widths);
/* FIXME */
for (i = 0; i < nbchars; i++) widths[i] = glyph_width[i];
return S_OK;
}

View file

@ -1,18 +1,18 @@
<module name="usp10" type="win32dll" installbase="system32" installname="usp10.dll" allowwarnings ="true"> <?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<group>
<module name="usp10" type="win32dll" baseaddress="${BASEADDRESS_USP10}" installbase="system32" installname="usp10.dll" allowwarnings="true">
<importlibrary definition="usp10.spec.def" /> <importlibrary definition="usp10.spec.def" />
<include base="usp10">.</include> <include base="usp10">.</include>
<include base="ReactOS">include/reactos/wine</include> <include base="ReactOS">include/reactos/wine</include>
<define name="UNICODE" /> <define name="__WINESRC__" />
<define name="_UNICODE" /> <define name="WINVER">0x600</define>
<define name="_WIN32_IE">0x600</define> <define name="_WIN32_WINNT">0x600</define>
<define name="_WIN32_WINNT">0x501</define>
<define name="WINVER">0x501</define>
<library>wine</library>
<library>uuid</library>
<library>ntdll</library>
<library>kernel32</library>
<library>user32</library>
<library>gdi32</library>
<file>usp10.c</file> <file>usp10.c</file>
<file>usp10.spec</file> <file>usp10.spec</file>
<library>wine</library>
<library>gdi32</library>
<library>kernel32</library>
<library>ntdll</library>
</module> </module>
</group>

View file

@ -8,7 +8,7 @@
@ stdcall ScriptGetCMap(ptr ptr ptr long long ptr) @ stdcall ScriptGetCMap(ptr ptr ptr long long ptr)
@ stdcall ScriptGetFontProperties(long ptr ptr) @ stdcall ScriptGetFontProperties(long ptr ptr)
@ stdcall ScriptGetGlyphABCWidth(ptr ptr long ptr) @ stdcall ScriptGetGlyphABCWidth(ptr ptr long ptr)
@ stub ScriptGetLogicalWidths @ stdcall ScriptGetLogicalWidths(ptr long long ptr ptr ptr ptr)
@ stdcall ScriptGetProperties(ptr long) @ stdcall ScriptGetProperties(ptr long)
@ stdcall ScriptIsComplex(wstr long long) @ stdcall ScriptIsComplex(wstr long long)
@ stdcall ScriptItemize(wstr long long ptr ptr ptr ptr) @ stdcall ScriptItemize(wstr long long ptr ptr ptr ptr)

View file

@ -1,22 +0,0 @@
Index: usp10.c
===================================================================
--- usp10.c (revision 25776)
+++ usp10.c (working copy)
@@ -35,6 +35,8 @@
#include "wine/debug.h"
#include "wine/unicode.h"
+DWORD STDCALL GetGlyphIndicesW( HDC hdc, LPCWSTR lpstr, int c, LPWORD pgi, DWORD fl);
+BOOL STDCALL GetCharABCWidthsI(HDC hdc, UINT giFirst, UINT cgi, LPWORD pgi, LPABC lpabc);
/**
* some documentation here:
* http://www.microsoft.com/typography/developers/uniscribe/uniscribe.htm
@@ -1241,7 +1243,7 @@
TRACE("\n");
if (!psa->fNoGlyphIndex) { /* Glyph translate */
- if (!(GetGlyphIndicesW(get_cache_hdc(psc), pwcChars, cChars, pwOutGlyphs, 0)))
+ if (!(GetGlyphIndicesW((HDC)get_cache_hdc(psc), (LPCWSTR) pwcChars, (int)cChars, (LPWORD) pwOutGlyphs,(DWORD) 0)))
return S_FALSE;
TRACE("After: ");