From 9982651fd684577e977d85d0bc54bea65d8c3ff1 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Wed, 9 Jan 2019 08:29:41 +0100 Subject: [PATCH] CJKutf8 is only to be used with the dedicated utf8-cjk encoding --- lib/examples/ko/splash.lyx | 2 +- src/BufferParams.cpp | 2 +- src/output_latex.cpp | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/examples/ko/splash.lyx b/lib/examples/ko/splash.lyx index 831f6bb4a0..ca01186ef0 100644 --- a/lib/examples/ko/splash.lyx +++ b/lib/examples/ko/splash.lyx @@ -9,7 +9,7 @@ \maintain_unincluded_children false \language korean \language_package default -\inputencoding utf8 +\inputencoding utf8-cjk \fontencoding OT1 \font_roman "default" "NanumMyeongjo" \font_sans "default" "NanumGothic" diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 8de7bc5a75..7b2c0886a1 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -3276,7 +3276,7 @@ void BufferParams::writeEncodingPreamble(otexstream & os, // Load the CJK package if needed by a secondary language. // If the main encoding is some variant of UTF8, use CJKutf8. if (encoding().package() != Encoding::CJK && features.mustProvide("CJK")) { - if (encoding().iconvName() == "UTF-8" + if (language->encoding()->name() == "utf8-cjk" && LaTeXFeatures::isAvailable("CJKutf8")) os << "\\usepackage{CJKutf8}\n"; else diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 55e6c67d1d..af7d5c971c 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -307,7 +307,7 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf, if (data.par_language->encoding()->package() == Encoding::CJK && state->open_encoding_ != CJK && pit->isMultiLingual(bparams)) { if (prev_par_language->encoding()->package() == Encoding::CJK) { - docstring const cjkenc = (bparams.encoding().iconvName() == "UTF-8" + docstring const cjkenc = (bparams.encoding().name() == "utf8-cjk" && LaTeXFeatures::isAvailable("CJKutf8")) ? from_ascii("UTF8") : from_ascii(data.par_language->encoding()->latexName()); @@ -999,7 +999,7 @@ void TeXOnePar(Buffer const & buf, // context (nesting issue). if (par_language->encoding()->package() == Encoding::CJK && state->open_encoding_ != CJK && state->cjk_inherited_ == 0) { - docstring const cjkenc = (bparams.encoding().iconvName() == "UTF-8" + docstring const cjkenc = (bparams.encoding().name() == "utf8-cjk" && LaTeXFeatures::isAvailable("CJKutf8")) ? from_ascii("UTF8") : from_ascii(par_language->encoding()->latexName()); @@ -1406,8 +1406,10 @@ void latexParagraphs(Buffer const & buf, // (but not in child documents) OutputState * state = getOutputState(); if (maintext && !is_child && !bparams.useNonTeXFonts - && bparams.language->encoding()->package() == Encoding::CJK) { - docstring const cjkenc = (bparams.encoding().iconvName() == "UTF-8" + && bparams.language->encoding()->package() == Encoding::CJK + && (bparams.encoding().name() == "utf8-cjk" + || bparams.encoding().iconvName() != "UTF-8")) { + docstring const cjkenc = (bparams.encoding().name() == "utf8-cjk" && LaTeXFeatures::isAvailable("CJKutf8")) ? from_ascii("UTF8") : from_ascii(bparams.encoding().latexName()); @@ -1605,7 +1607,7 @@ pair switchEncoding(odocstream & os, BufferParams const & bparams, bool const from_to_cjk = ((oldEnc.package() == Encoding::CJK && newEnc.package() != Encoding::CJK) || (oldEnc.package() != Encoding::CJK && newEnc.package() == Encoding::CJK)) - && (bparams.inputenc != "utf8" && LaTeXFeatures::isAvailable("CJKutf8")); + && (bparams.encoding().name() != "utf8-cjk" || !LaTeXFeatures::isAvailable("CJKutf8")); if (!force && !from_to_cjk && ((bparams.inputenc != "auto" && bparams.inputenc != "default") || moving_arg)) return make_pair(false, 0); @@ -1677,7 +1679,7 @@ pair switchEncoding(odocstream & os, BufferParams const & bparams, os << "\\egroup"; count += 7; } - docstring const cjkenc = (bparams.encoding().iconvName() == "UTF-8" + docstring const cjkenc = (bparams.encoding().name() == "utf8-cjk" && LaTeXFeatures::isAvailable("CJKutf8")) ? from_ascii("UTF8") : from_ascii(bparams.encoding().latexName());