]> git.lyx.org Git - lyx.git/blobdiff - src/Font.cpp
SCons: msvc does not need this /TP option any more after we rename .C => .cpp. Also...
[lyx.git] / src / Font.cpp
index 78b79ed8c2faf12f77c8d3a060e9cec779995611..b0073ebeb8e109883e94008664b42dc74f8a70c8 100644 (file)
 
 #include "support/lstrings.h"
 
-
-namespace lyx {
-
-using support::ascii_lowercase;
-using support::bformat;
-using support::rtrim;
-using support::subst;
-
 using std::endl;
 using std::string;
 using std::ostream;
+using std::pair;
 
 #ifndef CXX_GLOBAL_CSTD
 using std::strlen;
 #endif
 
+
+namespace lyx {
+
+using support::ascii_lowercase;
+using support::bformat;
+using support::rtrim;
+using support::subst;
+
 //
 // Names for the GUI
 //
@@ -756,6 +757,14 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
                            base.language()->lang() == "farsi") {
                        os << "\\textLR{";
                        count += 8;
+               } else if (language()->lang() == "arabic_arabi") {
+                       os << "\\textAR{";
+                       count += 8;
+               } else if (!isRightToLeft() &&
+                               base.language()->lang() == "arabic_arabi") {
+                       os << "\\textLR{";
+                       count += 8;
+               // currently the remaining RTL languages are arabic_arabtex and hebrew
                } else if (isRightToLeft() != prev.isRightToLeft()) {
                        if (isRightToLeft()) {
                                os << "\\R{";
@@ -777,12 +786,12 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
        }
 
        if (language()->encoding()->package() == Encoding::CJK) {
-               int const c = switchEncoding(os, bparams,
+               pair<bool, int> const c = switchEncoding(os, bparams,
                                runparams.moving_arg, *(runparams.encoding),
                                *(language()->encoding()));
-               if (c > 0) {
+               if (c.first) {
                        open_encoding_ = true;
-                       count += c;
+                       count += c.second;
                        runparams.encoding = language()->encoding();
                }
        }
@@ -793,7 +802,8 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
        // for Hebrew and Farsi (Arabi) do not.
        if (number() == ON && prev.number() != ON
                && (language()->lang() == "hebrew"
-                       || language()->lang() == "farsi")) {
+                       || language()->lang() == "farsi" 
+                       || language()->lang() == "arabic_arabi")) {
                os << "{\\beginL ";
                count += 9;
        }
@@ -866,7 +876,8 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
 int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
                                  OutputParams const & runparams,
                                  Font const & base,
-                                 Font const & next) const
+                                 Font const & next,
+                                 bool const & closeLanguage) const
 {
        int count = 0;
        bool env = false;
@@ -926,7 +937,8 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
        // for Hebrew and Farsi (Arabi) do not.
        if (number() == ON && next.number() != ON
                && (language()->lang() == "hebrew"
-                       || language()->lang() == "farsi")) {
+                       || language()->lang() == "farsi"
+                       || language()->lang() == "arabic_arabi")) {
                os << "\\endL}";
                count += 6;
        }
@@ -935,16 +947,17 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
                // We need to close the encoding even if it does not change
                // to do correct environment nesting
                Encoding const * const ascii = encodings.getFromLyXName("ascii");
-               int const c = switchEncoding(os, bparams,
+               pair<bool, int> const c = switchEncoding(os, bparams,
                                runparams.moving_arg, *(runparams.encoding),
                                *ascii);
-               BOOST_ASSERT(c > 0);
-               count += c;
+               BOOST_ASSERT(c.first);
+               count += c.second;
                runparams.encoding = ascii;
                open_encoding_ = false;
        }
 
-       if (language() != base.language() && language() != next.language()) {
+       if (closeLanguage &&
+                       language() != base.language() && language() != next.language()) {
                os << '}';
                ++count;
        }