The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 0b5c20fc0ff12d4f3981faf92deb9081452ecabf
Author: Juergen Spitzmueller <[email protected]>
Date:   Mon Jul 23 14:56:00 2012 +0200

    Fix direction of brackets in Hebrew when using Polyglossia (bug #8251)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 807abbd..8126a2f 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -330,6 +330,7 @@ public:
        ///
        void latexSpecialChar(
                                   otexstream & os,
+                                  BufferParams const & bparams,
                                   OutputParams const & runparams,
                                   Font const & running_font,
                                   Change const & running_change,
@@ -1156,6 +1157,7 @@ void Paragraph::Private::latexInset(BufferParams const & 
bparams,
 
 
 void Paragraph::Private::latexSpecialChar(otexstream & os,
+                                         BufferParams const & bparams,
                                          OutputParams const & runparams,
                                          Font const & running_font,
                                          Change const & running_change,
@@ -1164,7 +1166,10 @@ void Paragraph::Private::latexSpecialChar(otexstream & 
os,
                                          pos_type end_pos,
                                          unsigned int & column)
 {
-       char_type const c = text_[i];
+       // With polyglossia, brackets and stuff need not be reversed
+       // in RTL scripts (see bug #8251)
+       char_type const c = (runparams.use_polyglossia) ?
+               owner_->getUChar(bparams, i) : text_[i];
 
        if (style.pass_thru || runparams.pass_thru) {
                if (c != '\0') {
@@ -1897,16 +1902,23 @@ FontSize Paragraph::highestFontInRange
 char_type Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
 {
        char_type c = d->text_[pos];
-       if (!lyxrc.rtl_support)
+       if (!lyxrc.rtl_support || !getFontSettings(bparams, 
pos).isRightToLeft())
                return c;
 
+       // FIXME: The arabic special casing is due to the difference of arabic
+       // round brackets input introduced in r18599. Check if this should be
+       // unified with Hebrew or at least if all bracket types should be
+       // handled the same (file format change in either case).
+       string const & lang = getFontSettings(bparams, pos).language()->lang();
+       bool const arabic = lang == "arabic_arabtex" || lang == "arabic_arabi" 
||
+                                               lang == "farsi";
        char_type uc = c;
        switch (c) {
        case '(':
-               uc = ')';
+               uc = arabic ? c : ')';
                break;
        case ')':
-               uc = '(';
+               uc = arabic ? c : '(';
                break;
        case '[':
                uc = ']';
@@ -1927,9 +1939,8 @@ char_type Paragraph::getUChar(BufferParams const & 
bparams, pos_type pos) const
                uc = '<';
                break;
        }
-       if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
-               return uc;
-       return c;
+
+       return uc;
 }
 
 
@@ -2567,7 +2578,7 @@ void Paragraph::latex(BufferParams const & bparams,
                } else {
                        if (i >= start_pos && (end_pos == -1 || i < end_pos)) {
                                try {
-                                       d->latexSpecialChar(os, rp, 
running_font, runningChange,
+                                       d->latexSpecialChar(os, bparams, rp, 
running_font, runningChange,
                                                            style, i, end_pos, 
column);
                                } catch (EncodingException & e) {
                                if (runparams.dryrun) {
diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp
index c33bd79..7c7fd3e 100644
--- a/src/rowpainter.cpp
+++ b/src/rowpainter.cpp
@@ -237,6 +237,8 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const 
& font,
        str.reserve(100);
        str.push_back(prev_char);
 
+       // FIXME: Why only round brackets and why the difference to
+       // Hebrew? See also Paragraph::getUChar
        if (arabic) {
                char_type c = str[0];
                if (c == '(')
@@ -326,6 +328,8 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const 
& font,
                        break;
                */
 
+               // FIXME: Why only round brackets and why the difference to
+               // Hebrew? See also Paragraph::getUChar
                if (arabic) {
                        if (c == '(')
                                c = ')';

-----------------------------------------------------------------------

Summary of changes:
 src/Paragraph.cpp  |   27 +++++++++++++++++++--------
 src/rowpainter.cpp |    4 ++++
 2 files changed, 23 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to