]> git.lyx.org Git - features.git/commitdiff
Proper logos with RTL
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 15 Jul 2018 18:56:55 +0000 (20:56 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 9 Sep 2018 10:17:03 +0000 (12:17 +0200)
Fixes #10423

(cherry picked from commit e5a9244bef8b7d86ae86fa2d180adbd0c47b70f1)

src/LaTeXFeatures.cpp
src/LaTeXFeatures.h
src/insets/InsetSpecialChar.cpp
status.23x

index 6b047bf775ada67a583e98d357af451c555aec8b..f325d9447b6d3b07844b650b756c9af525583b56 100644 (file)
@@ -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"))
index 72451ad8eeb80bc6505dba456d5f6fe7cd28ec64..137f5d7ebf7c0cf05cf09dabc78ba7501a9700a9 100644 (file)
@@ -182,6 +182,8 @@ private:
        ///
        void useLayout(docstring const &, int);
        ///
+       bool hasRTLLanguage() const;
+       ///
        std::list<docstring> usedLayouts_;
        ///
        std::list<docstring> usedInsetLayouts_;
index 1267a75b376c499dfb5c80bc50c9e084011e578b..e9153cd900c43e81c51ae9155c02ac3048335d87 100644 (file)
@@ -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;
        }
 }
index 02edc3f16ecc9d1f29c02dc76e7ff3e3e3004ced..c68179ce409b7e7eb07e6358baf70ad9b2a2a36e 100644 (file)
@@ -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