From: Juergen Spitzmueller Date: Fri, 20 Apr 2018 18:00:01 +0000 (+0200) Subject: Align \textgreek and \textcyr with font encoding, part II X-Git-Tag: lyx-2.4.0dev-acb2ca7b~3599 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4e5e1de08612a5aa64c71c2b3ffc1d21ffc20251;p=features.git Align \textgreek and \textcyr with font encoding, part II Also embrace encodable chars to those macros if we don't have a font encoding that can handle the glyphs. Fixes the remaining part of #9637 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 61f2bfc762..97ecd4df41 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -1781,6 +1781,9 @@ Buffer::ExportStatus Buffer::writeLaTeXSource(otexstream & os, // (or not reached) and characters encodable in the current // encoding are not converted to ASCII-representation. + // Some macros rely on font encoding + runparams.main_fontenc = params().main_font_encoding(); + // If we are compiling a file standalone, even if this is the // child of some other buffer, let's cut the link here, so the // file is really independent and no concurring settings from diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index b623f05aa4..d8edbe10ad 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1372,16 +1372,20 @@ void Paragraph::Private::latexSpecialChar(otexstream & os, } } string fontenc; - if (running_font.language()->lang() == runparams.document_language) + if (running_font.language()->lang() == bparams.language->lang()) fontenc = runparams.main_fontenc; else fontenc = running_font.language()->fontenc(); - if (Encodings::isKnownScriptChar(c, script) - && prefixIs(latex.first, from_ascii("\\" + script))) - column += writeScriptChars(runparams, os, latex.first, - running_change, encoding, - fontenc, i) - 1; - else if (latex.second + // "Script chars" need to embraced in \textcyr and \textgreek notwithstanding + // whether they are encodable or not (it only depends on the font encoding) + if (!runparams.isFullUnicode() && Encodings::isKnownScriptChar(c, script)) { + docstring const wrapper = from_ascii("\\" + script + "{"); + docstring ltx = latex.first; + if (!prefixIs(ltx, wrapper)) + ltx = wrapper + latex.first + from_ascii("}"); + column += writeScriptChars(runparams, os, ltx, running_change, + encoding, fontenc, i) - 1; + } else if (latex.second && ((!prefixIs(nextlatex, '\\') && !prefixIs(nextlatex, '{') && !prefixIs(nextlatex, '}'))