]> git.lyx.org Git - features.git/commitdiff
Don't force encoding switch for Japanese "listings" auto-strings.
authorGünter Milde <milde@lyx.org>
Thu, 18 Apr 2019 13:20:06 +0000 (15:20 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:25 +0000 (15:48 +0200)
listings copes with variable-width encodings under platex.

src/DocIterator.cpp
src/Encoding.cpp
src/LaTeXFeatures.cpp
src/insets/InsetListings.cpp

index b4883aa2d7f048dcfafd18949321245d3d8960cf..d14e0b32ab27090c96ce2a57f1955e9731f1837e 100644 (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;
index 2b55e0ef5ccba36a12bdf6b733d9ed215c168cc8..ad380d78039d69f83ffa048bb14b3ed9a54c51b5 100644 (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") + " '";
index 301d3c175c744cd32fab830af1b5346555bd8fa6..b706cec17020df52b211ef3eecc66c209503b1c3 100644 (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(),
index 8ff6108c1c4b26d1637066e679cfd6a65c0498e5..b344241cadc50f611e3912ef709645f250bd7a4e 100644 (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;