commit a41d589e851a956ff27235841e6330bab552c0fe
Author: Juergen Spitzmueller <[email protected]>
Date:   Sun Jul 15 20:56:55 2018 +0200

    Proper logos with RTL
    
    Fixes #10423
    
    (cherry picked from commit e5a9244bef8b7d86ae86fa2d180adbd0c47b70f1)
---
 src/LaTeXFeatures.cpp           |   17 +++++++++++++++++
 src/LaTeXFeatures.h             |    2 ++
 src/insets/InsetSpecialChar.cpp |   22 +++++++++++++++++-----
 status.23x                      |    2 ++
 4 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 6b047bf..f325d94 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -65,6 +65,10 @@ namespace lyx {
 static docstring const lyx_def = from_ascii(
        
"\\providecommand{\\LyX}{L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}");
 
+static docstring const lyx_rtl_def = from_ascii(
+       "\\let\\@@LyX\\LyX\n"
+       "\\def\\LyX{\\@ensure@LTR{\\@@LyX}}");
+
 static docstring const lyx_hyperref_def = from_ascii(
        "\\providecommand{\\LyX}{\\texorpdfstring%\n"
        "  {L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}\n"
@@ -908,6 +912,17 @@ void LaTeXFeatures::getFontEncodings(vector<string> & 
encodings) const
                }
 }
 
+
+bool LaTeXFeatures::hasRTLLanguage() const
+{
+       if (params_.language->rightToLeft())
+               return true;
+       for (auto const & lang : UsedLanguages_)
+               if (lang->rightToLeft())
+                       return true;
+       return false;
+}
+
 namespace {
 
 char const * simplefeatures[] = {
@@ -1359,6 +1374,8 @@ TexString LaTeXFeatures::getMacros() const
                        macros << lyx_hyperref_def << '\n';
                else
                        macros << lyx_def << '\n';
+               if (runparams_.use_polyglossia && hasRTLLanguage())
+                       macros << lyx_rtl_def << '\n';
        }
 
        if (mustProvide("noun"))
diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h
index 72451ad..137f5d7 100644
--- a/src/LaTeXFeatures.h
+++ b/src/LaTeXFeatures.h
@@ -182,6 +182,8 @@ private:
        ///
        void useLayout(docstring const &, int);
        ///
+       bool hasRTLLanguage() const;
+       ///
        std::list<docstring> usedLayouts_;
        ///
        std::list<docstring> usedInsetLayouts_;
diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp
index 1267a75..e9153cd 100644
--- a/src/insets/InsetSpecialChar.cpp
+++ b/src/insets/InsetSpecialChar.cpp
@@ -16,6 +16,7 @@
 
 #include "Dimension.h"
 #include "Font.h"
+#include "Language.h"
 #include "LaTeXFeatures.h"
 #include "Lexer.h"
 #include "MetricsInfo.h"
@@ -416,6 +417,17 @@ void InsetSpecialChar::read(Lexer & lex)
 void InsetSpecialChar::latex(otexstream & os,
                             OutputParams const & rp) const
 {
+       bool const rtl = rp.local_font->isRightToLeft();
+       string lswitch = "";
+       string lswitche = "";
+       if (rtl && !rp.use_polyglossia) {
+               lswitch = "\\L{";
+               lswitche = "}";
+               if (rp.local_font->language()->lang() == "arabic_arabi"
+                   || rp.local_font->language()->lang() == "farsi")
+                       lswitch = "\\textLR{";
+       }
+       
        switch (kind_) {
        case HYPHENATION:
                os << "\\-";
@@ -433,7 +445,7 @@ void InsetSpecialChar::latex(otexstream & os,
                os << "\\ldots" << termcmd;
                break;
        case MENU_SEPARATOR:
-               if (rp.local_font->isRightToLeft())
+               if (rtl)
                        os << "\\lyxarrow*";
                else
                        os << "\\lyxarrow";
@@ -450,22 +462,22 @@ void InsetSpecialChar::latex(otexstream & os,
        case PHRASE_LYX:
                if (rp.moving_arg)
                        os << "\\protect";
-               os << "\\LyX" << termcmd;
+               os << lswitch << "\\LyX" << termcmd << lswitche;
                break;
        case PHRASE_TEX:
                if (rp.moving_arg)
                        os << "\\protect";
-               os << "\\TeX" << termcmd;
+               os << lswitch << "\\TeX" << termcmd << lswitche;
                break;
        case PHRASE_LATEX2E:
                if (rp.moving_arg)
                        os << "\\protect";
-               os << "\\LaTeXe" << termcmd;
+               os << lswitch << "\\LaTeXe" << termcmd << lswitche;
                break;
        case PHRASE_LATEX:
                if (rp.moving_arg)
                        os << "\\protect";
-               os << "\\LaTeX" << termcmd;
+               os << lswitch << "\\LaTeX" << termcmd << lswitche;
                break;
        }
 }
diff --git a/status.23x b/status.23x
index 02edc3f..c68179c 100644
--- a/status.23x
+++ b/status.23x
@@ -19,6 +19,8 @@ What's new
 
 - Support rotated table cells with linebreaks (bug 8085).
 
+- Add support for LyX logo in RTL output (bug 10423).
+
 
 * MISCELLANEOUS
 

Reply via email to