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.
This commit is contained in:
Günter Milde 2019-02-05 11:31:27 +01:00
parent 32e4a85e43
commit fc0ab1283c
4 changed files with 40 additions and 38 deletions

View File

@ -292,7 +292,7 @@
\TestPackage{booktabs} \TestPackage{booktabs}
\TestPackage{braille} \TestPackage{braille}
\TestPackage{breakurl} \TestPackage{breakurl}
\TestPackage{CJKutf8} \TestPackage{CJK}
\TestPackage{calc} \TestPackage{calc}
\TestPackage{cancel} \TestPackage{cancel}
\TestPackage{chapterbib} \TestPackage{chapterbib}

View File

@ -11,7 +11,7 @@
\language_package none \language_package none
\inputencoding iso8859-15 \inputencoding iso8859-15
\fontencoding auto \fontencoding auto
\font_roman "default" "default" \font_roman "lmodern" "default"
\font_sans "default" "default" \font_sans "default" "default"
\font_typewriter "default" "default" \font_typewriter "default" "default"
\font_math "auto" "auto" \font_math "auto" "auto"
@ -68,13 +68,14 @@
\papercolumns 1 \papercolumns 1
\papersides 1 \papersides 1
\paperpagestyle plain \paperpagestyle plain
\tracking_changes false \tracking_changes true
\output_changes false \output_changes false
\html_math_output 0 \html_math_output 0
\html_css_as_file 0 \html_css_as_file 0
\html_be_strict true \html_be_strict true
\html_latex_start <span class='latex'> \html_latex_start <span class='latex'>
\html_latex_end </span> \html_latex_end </span>
\author -1402925745 "Günter Milde"
\end_header \end_header
\begin_body \begin_body
@ -7297,14 +7298,18 @@ cprotect
\end_layout \end_layout
\begin_layout Subsection \begin_layout Subsection
CJKutf8 CJK
\change_deleted -1402925745 1549302375
utf8
\change_unchanged
\end_layout \end_layout
\begin_layout Description \begin_layout Description
Found: Found:
\begin_inset Info \begin_inset Info
type "package" type "package"
arg "CJKutf8" arg "CJK"
\end_inset \end_inset
@ -7317,18 +7322,30 @@ language/chinese/CJK/
\end_layout \end_layout
\begin_layout Description \begin_layout Description
Notes: The package Notes: The
\change_deleted -1402925745 1549302395
package
\family sans \family sans
CJKutf8 CJKutf8
\family default \family default
(part of the (part of the
\change_unchanged
\family sans \family sans
CJK CJK
\family default \family default
bundle) merges base \SpecialChar LaTeX bundle
\change_deleted -1402925745 1549302399
) merges base \SpecialChar LaTeX
's and CJK's UTF-8 support. 's and CJK's UTF-8 support.
It is needed to produce proper output with the combination of CJK, utf-8 It is needed to produce proper output with the combination of CJK, utf-8
encoding, and hyperref. encoding, and hyperref.
\change_inserted -1402925745 1549302480
provides simultaneous support for various Asian scripts in many encodings
(including Unicode).
\change_unchanged
\end_layout \end_layout
\begin_layout Subsection \begin_layout Subsection

View File

@ -1749,8 +1749,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
// (see autotests/export/latex/CJK/micro-sign_utf8-cjk-libertine.lyx) // (see autotests/export/latex/CJK/micro-sign_utf8-cjk-libertine.lyx)
if (!useNonTeXFonts && encoding().package() != Encoding::none if (!useNonTeXFonts && encoding().package() != Encoding::none
&& (encoding().package() == Encoding::CJK || features.mustProvide("CJK"))) { && (encoding().package() == Encoding::CJK || features.mustProvide("CJK"))) {
if (encoding().iconvName() == "UTF-8" if (encoding().iconvName() == "UTF-8")
&& LaTeXFeatures::isAvailable("CJKutf8"))
os << "\\usepackage{CJKutf8}\n"; os << "\\usepackage{CJKutf8}\n";
else else
os << "\\usepackage[encapsulated]{CJK}\n"; os << "\\usepackage[encapsulated]{CJK}\n";

View File

@ -307,11 +307,8 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf,
if (data.par_language->encoding()->package() == Encoding::CJK && if (data.par_language->encoding()->package() == Encoding::CJK &&
state->open_encoding_ != CJK && pit->isMultiLingual(bparams)) { state->open_encoding_ != CJK && pit->isMultiLingual(bparams)) {
if (prev_par_language->encoding()->package() == Encoding::CJK) { if (prev_par_language->encoding()->package() == Encoding::CJK) {
docstring const cjkenc = (bparams.encoding().name() == "utf8-cjk" os << "\\begin{CJK}{"
&& LaTeXFeatures::isAvailable("CJKutf8")) ? << from_ascii(data.par_language->encoding()->latexName())
from_ascii("UTF8")
: from_ascii(data.par_language->encoding()->latexName());
os << "\\begin{CJK}{" << cjkenc
<< "}{" << from_ascii(bparams.fonts_cjk) << "}%\n"; << "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
} }
state->open_encoding_ = CJK; state->open_encoding_ = CJK;
@ -1003,11 +1000,8 @@ void TeXOnePar(Buffer const & buf,
// context (nesting issue). // context (nesting issue).
if (par_language->encoding()->package() == Encoding::CJK if (par_language->encoding()->package() == Encoding::CJK
&& state->open_encoding_ != CJK && state->cjk_inherited_ == 0) { && state->open_encoding_ != CJK && state->cjk_inherited_ == 0) {
docstring const cjkenc = (bparams.encoding().name() == "utf8-cjk" os << "\\begin{CJK}{"
&& LaTeXFeatures::isAvailable("CJKutf8")) ? << from_ascii(par_language->encoding()->latexName())
from_ascii("UTF8")
: from_ascii(par_language->encoding()->latexName());
os << "\\begin{CJK}{" << cjkenc
<< "}{" << from_ascii(bparams.fonts_cjk) << "}%\n"; << "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
state->open_encoding_ = CJK; state->open_encoding_ = CJK;
} }
@ -1408,23 +1402,17 @@ void latexParagraphs(Buffer const & buf,
} }
// Open a CJK environment at the beginning of the main buffer // 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 main encoding requires the CJK package
// if the document's language requires CJK, // or the document encoding is utf8 and the CJK package is required
// if a secondary language requires CJK and the encoding is utf8, // (but not in child documents or documents using system fonts):
// or if the document encoding is utf8-cjk:
OutputState * state = getOutputState(); OutputState * state = getOutputState();
if (maintext && !is_child && !bparams.useNonTeXFonts if (maintext && !is_child && !bparams.useNonTeXFonts
&& ((bparams.language->encoding()->package() == Encoding::CJK && (bparams.encoding().package() == Encoding::CJK
&& (bparams.encoding().iconvName() != "UTF-8" || (bparams.encoding().name() == "utf8"
|| bparams.encoding().name() == "utf8-cjk" && bparams.language->encoding()->package() == Encoding::CJK)
|| bparams.encoding().name() == "utf8")) // FIXME: should test if any language requires CJK
|| (bparams.encoding().name() == "utf8-cjk" // && LaTeXFeatures::mustProvide("CJK"))
&& LaTeXFeatures::isAvailable("CJKutf8")) // error: cannot call member function bool lyx::LaTeXFeatures::mustProvide(const string&) const without object
// 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
)) { )) {
docstring const cjkenc = bparams.encoding().iconvName() == "UTF-8" docstring const cjkenc = bparams.encoding().iconvName() == "UTF-8"
? from_ascii("UTF8") : from_ascii(bparams.encoding().latexName()); ? from_ascii("UTF8") : from_ascii(bparams.encoding().latexName());
@ -1622,8 +1610,7 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
bool const from_to_cjk = bool const from_to_cjk =
((oldEnc.package() == Encoding::CJK && newEnc.package() != Encoding::CJK) ((oldEnc.package() == Encoding::CJK && newEnc.package() != Encoding::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") && (bparams.encoding().name() != "utf8-cjk" && bparams.encoding().name() != "utf8")
|| !LaTeXFeatures::isAvailable("CJKutf8"))
&& bparams.encoding().package() != Encoding::CJK; && bparams.encoding().package() != Encoding::CJK;
if (!force && !from_to_cjk if (!force && !from_to_cjk
&& ((bparams.inputenc != "auto" && bparams.inputenc != "default") || moving_arg)) && ((bparams.inputenc != "auto" && bparams.inputenc != "default") || moving_arg))
@ -1702,8 +1689,7 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
count += 7; count += 7;
} }
docstring const cjkenc = (bparams.encoding().iconvName() == "UTF-8" 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 << "}{" os << "\\begin{CJK}{" << cjkenc << "}{"
<< from_ascii(bparams.fonts_cjk) << "}"; << from_ascii(bparams.fonts_cjk) << "}";
state->open_encoding_ = CJK; state->open_encoding_ = CJK;