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

usp10: Rewrite ScriptStringCPtoX to make use of ScriptCPtoX.

parent 289005a7
...@@ -202,6 +202,7 @@ typedef struct { ...@@ -202,6 +202,7 @@ typedef struct {
SCRIPT_VISATTR* psva; SCRIPT_VISATTR* psva;
GOFFSET* pGoffset; GOFFSET* pGoffset;
ABC* abc; ABC* abc;
int iMaxPosX;
} StringGlyphs; } StringGlyphs;
typedef struct { typedef struct {
...@@ -824,6 +825,7 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString, ...@@ -824,6 +825,7 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
analysis->glyphs[i].psva = psva; analysis->glyphs[i].psva = psva;
analysis->glyphs[i].pGoffset = pGoffset; analysis->glyphs[i].pGoffset = pGoffset;
analysis->glyphs[i].abc = abc; analysis->glyphs[i].abc = abc;
analysis->glyphs[i].iMaxPosX= -1;
} }
*pssa = analysis; *pssa = analysis;
...@@ -932,11 +934,9 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa, ...@@ -932,11 +934,9 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa,
*/ */
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int* pX) HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int* pX)
{ {
int i, j; int i;
int runningX = 0; int runningX = 0;
int runningCp = 0;
StringAnalysis* analysis = ssa; StringAnalysis* analysis = ssa;
BOOL itemTrailing;
TRACE("(%p), %d, %d, (%p)\n", ssa, icp, fTrailing, pX); TRACE("(%p), %d, %d, (%p)\n", ssa, icp, fTrailing, pX);
...@@ -951,26 +951,36 @@ HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrai ...@@ -951,26 +951,36 @@ HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrai
for(i=0; i<analysis->numItems; i++) for(i=0; i<analysis->numItems; i++)
{ {
int CP = analysis->pItem[i+1].iCharPos - analysis->pItem[i].iCharPos;
int offset;
/* initialize max extents for uninitialized runs */
if (analysis->glyphs[i].iMaxPosX == -1)
{
if (analysis->pItem[i].a.fRTL) if (analysis->pItem[i].a.fRTL)
itemTrailing = !fTrailing; ScriptCPtoX(0, FALSE, CP, analysis->glyphs[i].numGlyphs, analysis->glyphs[i].pwLogClust,
analysis->glyphs[i].psva, analysis->glyphs[i].piAdvance,
&analysis->pItem[i].a, &analysis->glyphs[i].iMaxPosX);
else else
itemTrailing = fTrailing; ScriptCPtoX(CP, TRUE, CP, analysis->glyphs[i].numGlyphs, analysis->glyphs[i].pwLogClust,
for(j=0; j<analysis->glyphs[i].numGlyphs; j++) analysis->glyphs[i].psva, analysis->glyphs[i].piAdvance,
{ &analysis->pItem[i].a, &analysis->glyphs[i].iMaxPosX);
if(runningCp == icp && itemTrailing == FALSE)
{
*pX = runningX;
return S_OK;
} }
runningX += analysis->glyphs[i].piAdvance[j];
if(runningCp == icp && itemTrailing == TRUE) if (icp >= CP)
{ {
runningX += analysis->glyphs[i].iMaxPosX;
icp -= CP;
continue;
}
ScriptCPtoX(icp, fTrailing, CP, analysis->glyphs[i].numGlyphs, analysis->glyphs[i].pwLogClust,
analysis->glyphs[i].psva, analysis->glyphs[i].piAdvance,
&analysis->pItem[i].a, &offset);
runningX += offset;
*pX = runningX; *pX = runningX;
return S_OK; return S_OK;
} }
runningCp++;
}
}
/* icp out of range */ /* icp out of range */
analysis->invalid = TRUE; analysis->invalid = TRUE;
......
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