From fc0ab1283c7153c3c1a09febd0951ec45b4126bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Milde?= Date: Tue, 5 Feb 2019 11:31:27 +0100 Subject: [PATCH] Check for CJK instead of CJKutf8. The specific test was introduced in ef6be5f4 because CJKutf8 was relatively new (cf. lyx.org/trac/ticket/5386). 10 years on, CJKutf8 is an established part of the CJK bundle and we can skip the special test for CJKutf8 to make the logic considerabely simpler to read, maintain and debug. --- lib/chkconfig.ltx | 2 +- lib/doc/LaTeXConfig.lyx | 29 +++++++++++++++++++++------ src/BufferParams.cpp | 3 +-- src/output_latex.cpp | 44 ++++++++++++++--------------------------- 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 743e08bbc6..4b78d88545 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -292,7 +292,7 @@ \TestPackage{booktabs} \TestPackage{braille} \TestPackage{breakurl} -\TestPackage{CJKutf8} +\TestPackage{CJK} \TestPackage{calc} \TestPackage{cancel} \TestPackage{chapterbib} diff --git a/lib/doc/LaTeXConfig.lyx b/lib/doc/LaTeXConfig.lyx index c40f44324b..82a5188399 100644 --- a/lib/doc/LaTeXConfig.lyx +++ b/lib/doc/LaTeXConfig.lyx @@ -11,7 +11,7 @@ \language_package none \inputencoding iso8859-15 \fontencoding auto -\font_roman "default" "default" +\font_roman "lmodern" "default" \font_sans "default" "default" \font_typewriter "default" "default" \font_math "auto" "auto" @@ -68,13 +68,14 @@ \papercolumns 1 \papersides 1 \paperpagestyle plain -\tracking_changes false +\tracking_changes true \output_changes false \html_math_output 0 \html_css_as_file 0 \html_be_strict true \html_latex_start \html_latex_end +\author -1402925745 "Günter Milde" \end_header \begin_body @@ -7297,14 +7298,18 @@ cprotect \end_layout \begin_layout Subsection -CJKutf8 +CJK +\change_deleted -1402925745 1549302375 +utf8 +\change_unchanged + \end_layout \begin_layout Description Found: \begin_inset Info type "package" -arg "CJKutf8" +arg "CJK" \end_inset @@ -7317,18 +7322,30 @@ language/chinese/CJK/ \end_layout \begin_layout Description -Notes: The package +Notes: The +\change_deleted -1402925745 1549302395 +package \family sans CJKutf8 \family default (part of the +\change_unchanged + \family sans CJK \family default - bundle) merges base \SpecialChar LaTeX + bundle +\change_deleted -1402925745 1549302399 +) merges base \SpecialChar LaTeX 's and CJK's UTF-8 support. It is needed to produce proper output with the combination of CJK, utf-8 encoding, and hyperref. + +\change_inserted -1402925745 1549302480 + provides simultaneous support for various Asian scripts in many encodings + (including Unicode). +\change_unchanged + \end_layout \begin_layout Subsection diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 4295954911..aad6ecef0d 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1749,8 +1749,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, // (see autotests/export/latex/CJK/micro-sign_utf8-cjk-libertine.lyx) if (!useNonTeXFonts && encoding().package() != Encoding::none && (encoding().package() == Encoding::CJK || features.mustProvide("CJK"))) { - if (encoding().iconvName() == "UTF-8" - && LaTeXFeatures::isAvailable("CJKutf8")) + if (encoding().iconvName() == "UTF-8") os << "\\usepackage{CJKutf8}\n"; else os << "\\usepackage[encapsulated]{CJK}\n"; diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 47e92c1726..23068de131 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -307,11 +307,8 @@ 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().name() == "utf8-cjk" - && LaTeXFeatures::isAvailable("CJKutf8")) ? - from_ascii("UTF8") - : from_ascii(data.par_language->encoding()->latexName()); - os << "\\begin{CJK}{" << cjkenc + os << "\\begin{CJK}{" + << from_ascii(data.par_language->encoding()->latexName()) << "}{" << from_ascii(bparams.fonts_cjk) << "}%\n"; } state->open_encoding_ = CJK; @@ -1003,11 +1000,8 @@ 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().name() == "utf8-cjk" - && LaTeXFeatures::isAvailable("CJKutf8")) ? - from_ascii("UTF8") - : from_ascii(par_language->encoding()->latexName()); - os << "\\begin{CJK}{" << cjkenc + os << "\\begin{CJK}{" + << from_ascii(par_language->encoding()->latexName()) << "}{" << from_ascii(bparams.fonts_cjk) << "}%\n"; state->open_encoding_ = CJK; } @@ -1408,23 +1402,17 @@ void latexParagraphs(Buffer const & buf, } // Open a CJK environment at the beginning of the main buffer - // (but not in child documents or documents using system fonts) - // if the document's language requires CJK, - // if a secondary language requires CJK and the encoding is utf8, - // or if the document encoding is utf8-cjk: + // if the document's main encoding requires the CJK package + // or the document encoding is utf8 and the CJK package is required + // (but not in child documents or documents using system fonts): OutputState * state = getOutputState(); if (maintext && !is_child && !bparams.useNonTeXFonts - && ((bparams.language->encoding()->package() == Encoding::CJK - && (bparams.encoding().iconvName() != "UTF-8" - || bparams.encoding().name() == "utf8-cjk" - || bparams.encoding().name() == "utf8")) - || (bparams.encoding().name() == "utf8-cjk" - && LaTeXFeatures::isAvailable("CJKutf8")) - // FIXME: test for secondary language requiring CJK - // || (LaTeXFeatures::mustProvide("CJK")) - // && bparams.encoding().name() == "utf8" - // && LaTeXFeatures::isAvailable("CJKutf8")) - // error: cannot call member function ‘bool lyx::LaTeXFeatures::mustProvide(const string&) const’ without object + && (bparams.encoding().package() == Encoding::CJK + || (bparams.encoding().name() == "utf8" + && bparams.language->encoding()->package() == Encoding::CJK) + // FIXME: should test if any language requires CJK + // && LaTeXFeatures::mustProvide("CJK")) + // error: cannot call member function ‘bool lyx::LaTeXFeatures::mustProvide(const string&) const’ without object )) { docstring const cjkenc = bparams.encoding().iconvName() == "UTF-8" ? from_ascii("UTF8") : from_ascii(bparams.encoding().latexName()); @@ -1622,8 +1610,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.encoding().name() != "utf8-cjk" && bparams.encoding().name() != "utf8") - || !LaTeXFeatures::isAvailable("CJKutf8")) + && (bparams.encoding().name() != "utf8-cjk" && bparams.encoding().name() != "utf8") && bparams.encoding().package() != Encoding::CJK; if (!force && !from_to_cjk && ((bparams.inputenc != "auto" && bparams.inputenc != "default") || moving_arg)) @@ -1702,8 +1689,7 @@ pair switchEncoding(odocstream & os, BufferParams const & bparams, count += 7; } docstring const cjkenc = (bparams.encoding().iconvName() == "UTF-8" - && LaTeXFeatures::isAvailable("CJKutf8")) - ? from_ascii("UTF8") : from_ascii(newEnc.latexName()); + ? from_ascii("UTF8") : from_ascii(newEnc.latexName())); os << "\\begin{CJK}{" << cjkenc << "}{" << from_ascii(bparams.fonts_cjk) << "}"; state->open_encoding_ = CJK;