]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetSpecialChar.cpp
Proper logos with RTL
[lyx.git] / src / insets / InsetSpecialChar.cpp
index 4d4198499a161c1f93d734da2449c9b0928cdd43..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"
@@ -84,7 +85,7 @@ int logoWidth(FontInfo const & font, InsetSpecialChar::Kind kind) {
        return width;
 }
 
-}
+} // namespace
 
 docstring InsetSpecialChar::toolTip(BufferView const &, int, int) const
 {
@@ -108,6 +109,14 @@ docstring InsetSpecialChar::toolTip(BufferView const &, int, int) const
                case NOBREAKDASH:
                        message = from_ascii("Protected Hyphen (SHY)");
                        break;
+               case LDOTS:
+               case MENU_SEPARATOR:
+               case PHRASE_LYX:
+               case PHRASE_TEX:
+               case PHRASE_LATEX2E:
+               case PHRASE_LATEX:
+                       // no tooltip for these ones.
+                       break;
        }
        return message;
 }
@@ -240,7 +249,7 @@ void drawLogo(PainterInfo & pi, int & x, int const y, InsetSpecialChar::Kind kin
        }
 }
 
-}
+} // namespace
 
 void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
 {
@@ -408,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 << "\\-";
@@ -425,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";
@@ -442,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;
        }
 }