From c02cbaa0a30d9fefee306e8603dd92a1c1efa390 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnter=20Milde?= Date: Thu, 7 Mar 2019 17:01:05 +0100 Subject: [PATCH] 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 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 76dc31c0ec..e2f32b5583 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")) -- 2.39.5