Currently (only) Unicode is used for Farsi as the input encoding. Moreover in 
Unicode the openning parenthesis is always the left one (independent of the 
language) I have modified the code to reverse the direction of the 
character-pairs when it wants to display the characters whenever the language 
is Arabic or Farsi. Maybe the direction should be changed only when the 
language is Farsi (not Arabic), but only one parameter, i.e. bool Arabic, is 
sent to the function). 

Mostafa

Index: rowpainter.cpp

===================================================================

--- rowpainter.cpp    (revision 18837)

+++ rowpainter.cpp    (working copy)

@@ -302,6 +302,46 @@

 }
 
 
+char_type reverseCharPair(char_type ch)
+{
+    char_type uc = ch;
+
+    switch (ch) {
+    case '(':
+        uc = ')';
+        break;
+    case ')':
+        uc = '(';
+        break;
+    case '[':
+        uc = ']';
+        break;
+    case ']':
+        uc = '[';
+        break;
+    case '{':
+        uc = '}';
+        break;
+    case '}':
+        uc = '{';
+        break;
+    case '<':
+        uc = '>';
+        break;
+    case '>':
+        uc = '<';
+        break;
+    case 187:
+        uc = 171;
+        break;
+    case 171:
+        uc = 187;
+        break;
+    }
+
+    return uc;
+}
+
 void RowPainter::paintChars(pos_type & vpos, Font const & font,
                 bool hebrew, bool arabic)
 {
@@ -318,10 +358,7 @@

 
     if (arabic) {
         char_type c = str[0];
-        if (c == '(')
-            c = ')';
-        else if (c == ')')
-            c = '(';
+        c = reverseCharPair(c);
         str[0] = par_.transformChar(c, pos);
     }
 
@@ -366,10 +403,7 @@

         */
 
         if (arabic) {
-            if (c == '(')
-                c = ')';
-            else if (c == ')')
-                c = '(';
+            c = reverseCharPair(c);
             c = par_.transformChar(c, pos);
             /* see comment in hebrew, explaining why we break */
             break;

       
---------------------------------
Boardwalk for $500? In 2007? Ha! 
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.

Reply via email to