diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c index 5eb48e1f699..180bcfbb2fb 100644 --- a/dlls/usp10/tests/usp10.c +++ b/dlls/usp10/tests/usp10.c @@ -1910,6 +1910,21 @@ static void test_ScriptXtoX(void) else /* win2k3 */ ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP); + for (iX = 0; iX <= 7; iX++) + { + WORD clust = 0; + INT advance = 16; + hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing); + ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX, piCP,piTrailing); + } + for (iX = 8; iX < 16; iX++) + { + WORD clust = 0; + INT advance = 16; + hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing); + ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX, piCP,piTrailing); + } + sa.fRTL = TRUE; hr = ScriptXtoCP(-1, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing); ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr); @@ -1924,6 +1939,21 @@ static void test_ScriptXtoX(void) ok(piCP == -1, "iX=%d should return piCP=-1 not %d\n", iX, piCP); ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing); + for (iX = 1; iX <= 8; iX++) + { + WORD clust = 0; + INT advance = 16; + hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing); + ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX,piCP,piTrailing); + } + for (iX = 9; iX < 16; iX++) + { + WORD clust = 0; + INT advance = 16; + hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing); + ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX,piCP,piTrailing); + } + sa.fRTL = FALSE; test_item_ScriptXtoX(&sa, 10, 10, offsets, pwLogClust, piAdvance); sa.fRTL = TRUE; diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c index 527f7b841e6..df6f75a7ee9 100644 --- a/dlls/usp10/usp10.c +++ b/dlls/usp10/usp10.c @@ -1806,7 +1806,7 @@ HRESULT WINAPI ScriptXtoCP(int iX, { if (iPosX > iX) item--; - if (item < cChars && ((iPosX - iLastPosX) / 2.0) + iX > iPosX) + if (item < cChars && ((iPosX - iLastPosX) / 2.0) + iX >= iPosX) *piTrailing = 1; else *piTrailing = 0;