Proper logos with RTL

Fixes #10423

(cherry picked from commit e5a9244bef)
This commit is contained in:
Juergen Spitzmueller 2018-07-15 20:56:55 +02:00
parent 2e65b8e75e
commit a41d589e85
4 changed files with 38 additions and 5 deletions

View 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"))

View File

@ -182,6 +182,8 @@ private:
///
void useLayout(docstring const &, int);
///
bool hasRTLLanguage() const;
///
std::list<docstring> usedLayouts_;
///
std::list<docstring> usedInsetLayouts_;

View 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;
}
}

View 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