Proper logos with RTL

Fixes #10423
This commit is contained in:
Juergen Spitzmueller 2018-07-15 20:56:55 +02:00
parent 3bacc3c6e7
commit e5a9244bef
3 changed files with 36 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"
@ -914,6 +918,17 @@ void LaTeXFeatures::getFontEncodings(vector<string> & encs, bool const onlylangs
}
}
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[] = {
@ -1363,6 +1378,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

@ -185,6 +185,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;
}
}