Commit bdbab217 authored by Clinton Stimpson's avatar Clinton Stimpson Committed by Alexandre Julliard

usp10: Implement ScriptStringXtoCP.

parent 857e330e
......@@ -829,7 +829,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
todo_wine ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X);
todo_wine ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
iTrailing, X);
/*
......@@ -861,7 +861,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
todo_wine ok(Cp - 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp - 1, Ch, X);
todo_wine ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
iTrailing, X);
/*
......
......@@ -585,12 +585,55 @@ HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrai
*/
HRESULT WINAPI ScriptStringXtoCP(SCRIPT_STRING_ANALYSIS ssa, int iX, int* piCh, int* piTrailing)
{
FIXME("(%p), %d, (%p), (%p): stub\n", ssa, iX, piCh, piTrailing);
*piCh = 0; /* Set a reasonable value */
*piTrailing = 0;
StringAnalysis* analysis = ssa;
int i;
int j;
int runningX = 0;
int runningCp = 0;
int width;
TRACE("(%p), %d, (%p), (%p)\n", ssa, iX, piCh, piTrailing);
if(!ssa || !piCh || !piTrailing)
{
return 1;
}
/* out of range */
if(iX < 0)
{
*piCh = -1;
*piTrailing = TRUE;
return S_OK;
}
for(i=0; i<analysis->numItems; i++)
{
for(j=0; j<analysis->glyphs[i].numGlyphs; j++)
{
width = analysis->glyphs[i].piAdvance[j];
if(iX < (runningX + width))
{
*piCh = runningCp;
if((iX - runningX) > width/2)
*piTrailing = TRUE;
else
*piTrailing = FALSE;
return S_OK;
}
runningX += width;
runningCp++;
}
}
/* out of range */
*piCh = analysis->pItem[analysis->numItems].iCharPos;
*piTrailing = FALSE;
return S_OK;
}
/***********************************************************************
* ScriptStringFree (USP10.@)
*
......
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