[PATCH] gdi: Implement implicit resolving in BiDi

Maarten Lankhorst m.b.lankhorst at gmail.com
Sat Sep 15 08:17:58 CDT 2007


---
 dlls/gdi32/bidi.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/dlls/gdi32/bidi.c b/dlls/gdi32/bidi.c
index 4d20231..0891f78 100644
--- a/dlls/gdi32/bidi.c
+++ b/dlls/gdi32/bidi.c
@@ -754,6 +754,50 @@ static void resolveNeutrals(int baselevel, WORD *pcls, const WORD *plevel, int c
         SetDeferredRun(pcls, cchRun, ich, clsRun);
 }
 
+/* RESOLVE IMPLLICIT */
+
+/*------------------------------------------------------------------------
+    Function: resolveImplicit
+
+    Recursively resolves implicit embedding levels.
+    Implements rules I1 and I2 of the Unicode Bidirectional Algorithm.
+
+    Input: Array of direction classes
+           Character count
+           Base level
+
+    In/Out: Array of embedding levels
+
+    Note: levels may exceed 15 on output.
+          Accepted subset of direction classes
+          R, L, AN, EN
+------------------------------------------------------------------------*/
+static WORD addLevel[][4] =
+{
+          /* L,  R, AN, EN */
+/* even */ { 0,  1,  2,  2, },
+/* odd  */ { 1,  0,  1,  1, }
+
+};
+
+static void resolveImplicit(const WORD * pcls, WORD *plevel, int cch)
+{
+    int ich = 0;
+    for (; ich < cch; ich++)
+    {
+        /* cannot resolve bn here, since some bn were resolved to strong
+         * types in resolveWeak. To remove these we need the original
+         * types, which are available again in resolveWhiteSpace */
+        if (pcls[ich] == BN)
+        {
+            continue;
+        }
+        ASSERT(pcls[ich] > 0); /* "No Neutrals allowed to survive here." */
+        ASSERT(pcls[ich] < 5); /* "Out of range." */
+        plevel[ich] += addLevel[odd(plevel[ich])][pcls[ich] - 1];
+    }
+}
+
 /*************************************************************
  *    BIDI_Reorder
  */
@@ -843,6 +887,9 @@ BOOL BIDI_Reorder(
         /* resolve neutrals */
         resolveNeutrals(baselevel, chartype, levels, i);
 
+        /* resolveImplicit */
+        resolveImplicit(chartype, levels, i);
+
         /* Temporary stub: Just reverse the odd levels */
         for (j = lastgood = 0; j < i; ++j)
             if (levels[j] != levels[lastgood])
-- 
1.5.2.5


--------------040205070004030902060006--



More information about the wine-patches mailing list