usp10: Add tests and fix for ScriptXtoCP .

This commit is contained in:
Clinton Stimpson 2006-12-11 22:23:53 -07:00 committed by Alexandre Julliard
parent aa8392c9e7
commit 39a5b0760c
2 changed files with 23 additions and 3 deletions

View File

@ -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;

View File

@ -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