commit 24b675783f7243a3b28a4965d91709ef02430a82
Author: Günter Milde <[email protected]>
Date:   Thu Mar 7 17:01:05 2019 +0100

    Ensure \LyX macro works also with non-standard font encodings (Greek, ...).
    
    Babel provides the \textlatin macro to ensure Latin letter ASCII characters 
are
    output as Latin letters.
    
    Instead of 8 different definitions for the several variants of the macro 
definition,
    wrappers are individually added if required and available.
---
 src/LaTeXFeatures.cpp |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 76dc31c..e2f32b5 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -63,16 +63,7 @@ namespace lyx {
 //\message{LyX LaTeX Extensions (LLE v0.2) of 11-Jan-1996.}
 
 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"
-       "  {LyX}}");
+       "{%\n  L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}");
 
 static docstring const noun_def = from_ascii(
        "\\newcommand{\\noun}[1]{\\textsc{#1}}");
@@ -929,6 +920,7 @@ bool LaTeXFeatures::hasRTLLanguage() const
        return false;
 }
 
+
 namespace {
 
 char const * simplefeatures[] = {
@@ -1380,12 +1372,24 @@ TexString LaTeXFeatures::getMacros() const
        }
 
        if (mustProvide("LyX")) {
+               macros << "\\providecommand{\\LyX}";
+               // open conditional wrappers
+               if (runparams_.use_polyglossia && hasRTLLanguage())
+                       macros << "{\\@ensure@LTR";
                if (isRequired("hyperref"))
-                       macros << lyx_hyperref_def << '\n';
-               else
-                       macros << lyx_def << '\n';
+                       macros << "{\\texorpdfstring";
+               if (useBabel())
+                       macros << "{\\textlatin";
+               // main definition
+               macros << lyx_def;
+               // close conditional wrappers
+               if (useBabel())
+                       macros << '}';
+               if (isRequired("hyperref"))
+                       macros << "{LyX}}";
                if (runparams_.use_polyglossia && hasRTLLanguage())
-                       macros << lyx_rtl_def << '\n';
+                       macros << '}';
+               macros << '\n';
        }
 
        if (mustProvide("noun"))

Reply via email to