Aric Stewart : usp10: Better understand and handle numbers level in RTL runs.

Alexandre Julliard julliard at winehq.org
Wed Nov 9 13:29:41 CST 2011


Module: wine
Branch: master
Commit: 65710af292995683537bdf707313e8638da81cdf
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=65710af292995683537bdf707313e8638da81cdf

Author: Aric Stewart <aric at codeweavers.com>
Date:   Tue Nov  8 14:41:53 2011 -0600

usp10: Better understand and handle numbers level in RTL runs.

---

 dlls/usp10/tests/usp10.c |    2 +-
 dlls/usp10/usp10.c       |   30 +++++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
index 13211de..a6e75a1 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 c1837d9..a811cad 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)
+            {
+                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)
             {
-                strength = heap_alloc_zero(cInChars * sizeof(WORD));
-                BIDI_GetStrengths(pwcInChars, cInChars, psControl, strength);
+                HeapFree(GetProcessHeap(),0,strength);
+                strength = NULL;
             }
         }
     }




More information about the wine-cvs mailing list