Commit 25e836e8 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

usp10: Do glyph translation for truetype fonts only.

parent c7278c21
...@@ -145,9 +145,8 @@ static const SCRIPT_PROPERTIES *script_props[] = ...@@ -145,9 +145,8 @@ static const SCRIPT_PROPERTIES *script_props[] =
typedef struct { typedef struct {
HDC hdc; HDC hdc;
LONG height;
WCHAR default_char;
LOGFONTW lf; LOGFONTW lf;
TEXTMETRICW tm;
} ScriptCache; } ScriptCache;
typedef struct { typedef struct {
...@@ -200,23 +199,23 @@ static HDC get_cache_hdc(SCRIPT_CACHE *psc) ...@@ -200,23 +199,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 HRESULT init_script_cache(const HDC hdc, ScriptCache *sc) static BYTE get_cache_pitch_family(SCRIPT_CACHE *psc)
{ {
TEXTMETRICW metric; return ((ScriptCache *)*psc)->tm.tmPitchAndFamily;
}
if (!GetTextMetricsW(hdc, &metric)) return E_INVALIDARG; static HRESULT init_script_cache(const HDC hdc, ScriptCache *sc)
{
if (!GetTextMetricsW(hdc, &sc->tm)) return E_INVALIDARG;
if (!GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(LOGFONTW), &sc->lf)) return E_INVALIDARG; if (!GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(LOGFONTW), &sc->lf)) return E_INVALIDARG;
sc->height = metric.tmHeight;
sc->default_char = metric.tmDefaultChar;
sc->hdc = hdc; sc->hdc = hdc;
return S_OK; return S_OK;
} }
...@@ -1260,15 +1259,16 @@ HRESULT WINAPI ScriptShape(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcChars, ...@@ -1260,15 +1259,16 @@ HRESULT WINAPI ScriptShape(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcChars,
hfont = select_cached_font(psc); hfont = select_cached_font(psc);
if (!psa->fNoGlyphIndex) { /* Glyph translate */ if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE) && !psa->fNoGlyphIndex)
if (!(GetGlyphIndicesW(get_cache_hdc(psc), pwcChars, cChars, pwOutGlyphs, 0))) {
return S_FALSE; GetGlyphIndicesW(get_cache_hdc(psc), pwcChars, cChars, pwOutGlyphs, 0);
} }
else { else
for (cnt = 0; cnt < cChars; cnt++) { /* no translate so set up */ {
pwOutGlyphs[cnt] = pwcChars[cnt]; /* copy in to out and */ TRACE("no glyph translation\n");
} for (cnt = 0; cnt < cChars; cnt++) pwOutGlyphs[cnt] = pwcChars[cnt];
} }
if (psva) if (psva)
{ {
/* set up a valid SCRIPT_VISATTR and LogClust for each char in this run */ /* set up a valid SCRIPT_VISATTR and LogClust for each char in this run */
...@@ -1311,10 +1311,10 @@ HRESULT WINAPI ScriptPlace(HDC hdc, SCRIPT_CACHE *psc, const WORD *pwGlyphs, ...@@ -1311,10 +1311,10 @@ 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; 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);
...@@ -1328,38 +1328,39 @@ HRESULT WINAPI ScriptPlace(HDC hdc, SCRIPT_CACHE *psc, const WORD *pwGlyphs, ...@@ -1328,38 +1328,39 @@ HRESULT WINAPI ScriptPlace(HDC hdc, SCRIPT_CACHE *psc, const WORD *pwGlyphs,
* 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 = heap_alloc_zero(sizeof(ABC) * cGlyphs))) return E_OUTOFMEMORY; if (!(lpABC = heap_alloc_zero(sizeof(ABC) * cGlyphs))) return E_OUTOFMEMORY;
if (pABC) if (pABC) memset(pABC, 0, sizeof(ABC));
memset(pABC, 0, sizeof(ABC));
/* FIXME: set pGoffset to more reasonable values */ if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE) && !psa->fNoGlyphIndex)
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++)
{
if (pGoffset) pGoffset[wcnt].du = pGoffset[wcnt].dv = 0;
if (piAdvance) piAdvance[wcnt] = 0;
}
} }
else else
{ {
for (wcnt = 0; wcnt < cGlyphs; wcnt++) /* add up the char lengths */ INT width;
for (i = 0; i < cGlyphs; i++)
{ {
TRACE(" Glyph=%04x, abcA=%d, abcB=%d, abcC=%d wcnt=%d\n", GetCharWidth32W(get_cache_hdc(psc), pwGlyphs[i], pwGlyphs[i], &width);
pwGlyphs[wcnt], lpABC[wcnt].abcA, lpABC[wcnt].abcB, lpABC[wcnt].abcC, wcnt); lpABC[i].abcB = width;
}
}
if (pABC) for (i = 0; i < cGlyphs; i++)
{ {
pABC->abcA += lpABC[wcnt].abcA; TRACE(" Glyph=%04x, abcA=%d, abcB=%d, abcC=%d index=%d\n",
pABC->abcB += lpABC[wcnt].abcB; pwGlyphs[i], lpABC[i].abcA, lpABC[i].abcB, lpABC[i].abcC, i);
pABC->abcC += lpABC[wcnt].abcC;
} if (pABC)
if (pGoffset) pGoffset[wcnt].du = pGoffset[wcnt].dv = 0; {
if (piAdvance) piAdvance[wcnt] = lpABC[wcnt].abcA + lpABC[wcnt].abcB + lpABC[wcnt].abcC; 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); if (pABC) TRACE("Total for run: abcA=%d, abcB=%d, abcC=%d\n", pABC->abcA, pABC->abcB, pABC->abcC);
heap_free(lpABC); heap_free(lpABC);
unselect_cached_font(psc, hfont); unselect_cached_font(psc, hfont);
...@@ -1620,7 +1621,7 @@ const SIZE * WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa) ...@@ -1620,7 +1621,7 @@ const SIZE * WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
if (!analysis->sz) if (!analysis->sz)
{ {
if (!(analysis->sz = heap_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++)
......
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