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

usp10: Implement ScriptStringCPtoX.

parent bdbab217
...@@ -795,10 +795,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc) ...@@ -795,10 +795,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr); ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing); hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr); ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
if(Cp == 0)
ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X); ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X);
else
todo_wine ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X);
ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n", ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
iTrailing, X); iTrailing, X);
fTrailing = TRUE; fTrailing = TRUE;
...@@ -812,11 +809,10 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc) ...@@ -812,11 +809,10 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
* one input to ScriptStringCPtoX. This means that the Cp to X position and back * one input to ScriptStringCPtoX. This means that the Cp to X position and back
* again works * again works
*/ */
todo_wine ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, X); ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, X);
ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n", ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
iTrailing, X); iTrailing, X);
} }
/* /*
* This test is to check that if the X position is just inside the trailing edge of the * This test is to check that if the X position is just inside the trailing edge of the
* character then iTrailing will indicate the trailing edge, ie. TRUE * character then iTrailing will indicate the trailing edge, ie. TRUE
...@@ -828,7 +824,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc) ...@@ -828,7 +824,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
X--; /* put X just inside the trailing edge */ X--; /* put X just inside the trailing edge */
hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing); hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr); 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); ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X);
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); iTrailing, X);
...@@ -844,7 +840,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc) ...@@ -844,7 +840,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
X++; /* put X just outside the trailing edge */ X++; /* put X just outside the trailing edge */
hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing); hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr); 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); ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, X);
ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n", ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
iTrailing, X); iTrailing, X);
...@@ -860,7 +856,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc) ...@@ -860,7 +856,7 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
X--; /* put X just outside the leading edge */ X--; /* put X just outside the leading edge */
hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing); hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr); 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); ok(Cp - 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp - 1, Ch, X);
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); iTrailing, X);
...@@ -887,13 +883,13 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc) ...@@ -887,13 +883,13 @@ static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
fTrailing = FALSE; fTrailing = FALSE;
Cp = String_len + 1; Cp = String_len + 1;
hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X); hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
todo_wine ok(hr == E_INVALIDARG, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr); ok(hr == E_INVALIDARG, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr);
hr = ScriptStringFree(&ssa); hr = ScriptStringFree(&ssa);
/* /*
* ScriptStringCPtoX should free ssa, hence ScriptStringFree should fail * ScriptStringCPtoX should free ssa, hence ScriptStringFree should fail
*/ */
todo_wine ok(hr == E_INVALIDARG, "ScriptStringFree should return E_INVALIDARG not %08x\n", hr); ok(hr == E_INVALIDARG, "ScriptStringFree should return E_INVALIDARG not %08x\n", hr);
} }
} }
......
...@@ -574,9 +574,46 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa, ...@@ -574,9 +574,46 @@ 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)
{ {
FIXME("(%p), %d, %d, (%p): stub\n", ssa, icp, fTrailing, pX); int i, j;
*pX = 0; /* Set a reasonable value */ int runningX = 0;
int runningCp = 0;
StringAnalysis* analysis = ssa;
TRACE("(%p), %d, %d, (%p)\n", ssa, icp, fTrailing, pX);
if(!ssa || !pX)
{
return 1;
}
/* icp out of range */
if(icp < 0)
{
analysis->invalid = TRUE;
return E_INVALIDARG;
}
for(i=0; i<analysis->numItems; i++)
{
for(j=0; j<analysis->glyphs[i].numGlyphs; j++)
{
if(runningCp == icp && fTrailing == FALSE)
{
*pX = runningX;
return S_OK;
}
runningX += analysis->glyphs[i].piAdvance[j];
if(runningCp == icp && fTrailing == TRUE)
{
*pX = runningX;
return S_OK; return S_OK;
}
runningCp++;
}
}
/* icp out of range */
analysis->invalid = TRUE;
return E_INVALIDARG;
} }
/*********************************************************************** /***********************************************************************
......
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