Don't force encoding switch for Japanese "listings" auto-strings.

listings copes with variable-width encodings under platex.
This commit is contained in:
Günter Milde 2019-04-18 15:20:06 +02:00
parent 6eb9452836
commit 6dd505c67a
4 changed files with 12 additions and 5 deletions

View File

@ -738,6 +738,10 @@ Encoding const * DocIterator::getEncoding() const
if (bp.useNonTeXFonts)
return encodings.fromLyXName("utf8-plain");
// With platex, we don't switch encodings (not even if forced).
if (bp.encoding().package() == Encoding::japanese)
return &bp.encoding();
CursorSlice const & sl = innerTextSlice();
Text const & text = *sl.text();
Language const * lang =
@ -777,7 +781,7 @@ Encoding const * DocIterator::getEncoding() const
otext.outerFont(slices_[i].pit())).language();
// Again, if we have a custom encoding, this is used
// instead of the language's.
Encoding const * oenc = customenc
Encoding const * oenc = customenc
? &bp.encoding() : olang->encoding();
if (olang->encoding()->name() != "inherit")
return oenc;

View File

@ -230,8 +230,8 @@ pair<docstring, docstring> Encoding::latexString(docstring const & input, bool d
docstring uncodable;
bool terminate = false;
for (size_t n = 0; n < input.size(); ++n) {
char_type const c = input[n];
try {
char_type const c = input[n];
pair<docstring, bool> latex_char = latexChar(c);
docstring const latex = latex_char.first;
if (terminate && !prefixIs(latex, '\\')
@ -248,7 +248,8 @@ pair<docstring, docstring> Encoding::latexString(docstring const & input, bool d
result += latex;
terminate = latex_char.second;
} catch (EncodingException & /* e */) {
LYXERR0("Uncodable character in latexString!");
LYXERR0("Uncodable character <" << docstring(1, c)
<< "> in latexString!");
if (dryrun) {
result += "<" + _("LyX Warning: ")
+ _("uncodable character") + " '";

View File

@ -1913,9 +1913,11 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel,
// encodings, only with fixed width encodings. Therefore we
// need to force a fixed width encoding for
// \lstlistlistingname and \lstlistingname (bug 9382).
// This needs to be consistent with InsetListings::latex().
// This needs to be consistent with InsetListings::latex()
// rsp. InsetListings::forcedEncoding().
bool const need_fixedwidth = !use_minted &&
!runparams_.isFullUnicode() &&
buffer().params().encoding().package() != Encoding::japanese &&
it->second.fixedwidthpreambleencoding();
// language dependent commands (once per document)
snippets.insert(i18npreamble(it->second.langpreamble(),

View File

@ -127,7 +127,7 @@ Encoding const * InsetListings::forcedEncoding(Encoding const * inner_enc,
// Minted can deal with all encodings.
if (buffer().params().use_minted
|| inner_enc->name() == "utf8-plain"
|| buffer().params().encoding().package() == Encoding::japanese
|| inner_enc->package() == Encoding::japanese
|| inner_enc->hasFixedWidth())
return 0;