diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c index 13211dece4b..a6e75a1adad 100644 --- a/dlls/usp10/tests/usp10.c +++ b/dlls/usp10/tests/usp10.c @@ -153,7 +153,7 @@ static void test_ScriptItemize( void ) /* Arabic, English*/ static const WCHAR test2[] = {'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0}; static const itemTest t21[7] = {{{0,0,0,0,0},0,0,0,0,0},{{0,0,0,0,0},3,0,0,0,0},{{0,0,0,0,0},4,0,0,0,0},{{0,0,0,0,0},6,1,1,1,arab_tag},{{0,0,0,0,0},13,0,0,0,0},{{0,0,0,0,0},15,0,0,0,0},{{0,0,0,0,0},16,0,0,0,-1}}; - static const itemTest t22[5] = {{{0,0,0,1,0},0,0,0,2,0},{{0,0,0,0,0},6,1,1,1,arab_tag},{{0,0,1,0,0},13,0,1,2,0},{{0,0,0,0,0},15,0,0,0,0},{{0,0,0,0,0},16,0,0,0,-1}}; + static const itemTest t22[5] = {{{0,0,0,0,0},0,0,0,2,0},{{0,0,0,0,0},6,1,1,1,arab_tag},{{0,0,1,0,0},13,0,1,2,0},{{0,0,0,0,0},15,0,0,0,0},{{0,0,0,0,0},16,0,0,0,-1}}; static const itemTest t23[5] = {{{0,0,1,0,0},0,0,1,2,0},{{0,0,0,0,0},6,1,1,1,arab_tag},{{0,0,1,0,0},13,0,1,2,0},{{0,0,0,0,0},15,1,1,1,0},{{0,0,0,0,0},16,0,0,0,-1}}; static const WCHAR test2b[] = {'A','B','C','-','D','E','F',' ',0x0621,0x0623,0x0624,0}; diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c index c1837d914b9..a811cad61ef 100644 --- a/dlls/usp10/usp10.c +++ b/dlls/usp10/usp10.c @@ -806,10 +806,34 @@ HRESULT WINAPI ScriptItemizeOpenType(const WCHAR *pwcInChars, int cInChars, int } else { - if (!psControl->fMergeNeutralItems) + BOOL inNumber = FALSE; + static WCHAR math_punc[] = {'#','$','%','+',',','-','.','/',':',0x2212, 0x2044, 0x00a0,0}; + + strength = heap_alloc_zero(cInChars * sizeof(WORD)); + if (!strength) { - strength = heap_alloc_zero(cInChars * sizeof(WORD)); - BIDI_GetStrengths(pwcInChars, cInChars, psControl, strength); + heap_free(levels); + return E_OUTOFMEMORY; + } + BIDI_GetStrengths(pwcInChars, cInChars, psControl, strength); + + /* Script_Numeric and select puncuation at level 0 get bumped to level 2 */ + for (i = 0; i < cInChars; i++) + { + if ((levels[i] == 0 || (odd(psState->uBidiLevel) && levels[i] == psState->uBidiLevel+1)) && inNumber && strchrW(math_punc,pwcInChars[i])) + levels[i] = 2; + else if ((levels[i] == 0 || (odd(psState->uBidiLevel) && levels[i] == psState->uBidiLevel+1)) && get_char_script(pwcInChars[i]) == Script_Numeric) + { + levels[i] = 2; + inNumber = TRUE; + } + else + inNumber = FALSE; + } + if (psControl->fMergeNeutralItems) + { + HeapFree(GetProcessHeap(),0,strength); + strength = NULL; } } }