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{braille}
\TestPackage{breakurl}
\TestPackage{CJKutf8}
\TestPackage{CJK}
\TestPackage{calc}
\TestPackage{cancel}
\TestPackage{chapterbib}

View File

@ -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 <span class='latex'>
\html_latex_end </span>
\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

View File

@ -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";

View File

@ -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,22 +1402,16 @@ 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"))
&& (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"
@ -1622,8 +1610,7 @@ pair<bool, int> 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<bool, int> 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;