Commit 39a5b076 authored by Clinton Stimpson's avatar Clinton Stimpson Committed by Alexandre Julliard

usp10: Add tests and fix for ScriptXtoCP .

parent aa8392c9
......@@ -574,6 +574,25 @@ static void test_ScriptXtoX(void)
ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
ok(piCP == 4, "iX=%d should return piCP=4 not %d\n", iX, piCP);
iX = 0;
cChars = 10;
cGlyphs = 10;
hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
ok(piCP == 0, "iX=%d should return piCP=0 not %d\n", iX, piCP);
iX = 195;
cChars = 10;
cGlyphs = 10;
hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
ok(piCP == 0, "iX=%d should return piCP=0 not %d\n", iX, piCP);
iX = 196;
cChars = 10;
cGlyphs = 10;
hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
ok(piCP == 1, "iX=%d should return piCP=1 not %d\n", iX, piCP);
iCP=5;
fTrailing = FALSE;
cChars = 10;
......
......@@ -561,7 +561,7 @@ HRESULT WINAPI ScriptXtoCP(int iX,
int *piTrailing)
{
int item;
int iPosX = 1;
int iPosX;
float fMaxPosX = 1;
float fAvePosX;
TRACE("(%d,%d,%d,%p,%p,%p,%p,%p,%p)\n",
......@@ -585,8 +585,9 @@ HRESULT WINAPI ScriptXtoCP(int iX,
}
fAvePosX = fMaxPosX / cGlyphs;
for (item = 0; item < cGlyphs && iPosX < iX; item++)
iPosX = fAvePosX * (item +1);
iPosX = fAvePosX;
for (item = 1; item < cGlyphs && iPosX < iX; item++)
iPosX += fAvePosX;
if (iPosX - iX > fAvePosX/2)
*piTrailing = 0;
else
......
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