Fix for CJK-documents with input-encoding "utf8".

This commit is contained in:
Günter Milde 2019-01-28 17:49:58 +01:00
parent 7da76b1b9f
commit 34f5ba3c54
3 changed files with 18 additions and 14 deletions

View File

@ -105,7 +105,7 @@ For multi-lingual documents with parts in European languages, you can use
\begin_layout Enumerate
Short texts may be written without setting the language (hyphenation will
be missing and spell-checking complain): Greetings; Grüße; Приветы; χαιρετισμός
be missing and spell-checking complain): Greetings; Grüße; Приветы; χαιρετισμός.
\end_layout
\begin_layout Enumerate

View File

@ -86,7 +86,7 @@ export/examples/ja/multilingual_.*_systemF
# CJK for multilingual documents:
#
# input-encoding "utf8" should work for documents using a CJK language:
export/export/latex/CJK/.*-en-de-el-ru_utf8_pdf2
#export/export/latex/CJK/.*-en-de-el-ru_utf8_pdf2
#
# but that is not so easy if the main language does not require CJK:
export/export/latex/CJK/en-de-el-ru-.*_utf8_pdf2

View File

@ -1273,6 +1273,7 @@ void TeXOnePar(Buffer const & buf,
// If this is the last paragraph, close the CJK environment
// if necessary. If it's an environment, we'll have to \end that first.
// FIXME: don't close if the paragraph is nested in an environment
if (runparams.isLastPar && !style.isEnvironment()) {
switch (state->open_encoding_) {
case CJK: {
@ -1563,7 +1564,7 @@ void latexParagraphs(Buffer const & buf,
// If the last paragraph is an environment, we'll have to close
// CJK at the very end to do proper nesting.
if (maintext && !is_child && state->open_encoding_ == CJK) {
os << "\\end{CJK}\n";
os << "\\clearpage\n\\end{CJK}\n";
state->open_encoding_ = none;
}
// Likewise for polyglossia or when using begin/end commands
@ -1609,7 +1610,8 @@ 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" || !LaTeXFeatures::isAvailable("CJKutf8"));
&& ((bparams.encoding().name() != "utf8-cjk" && bparams.encoding().name() != "utf8")
|| !LaTeXFeatures::isAvailable("CJKutf8"));
if (!force && !from_to_cjk
&& ((bparams.inputenc != "auto" && bparams.inputenc != "default") || moving_arg))
return make_pair(false, 0);
@ -1629,11 +1631,14 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
if (oldEnc.package() == Encoding::none || newEnc.package() == Encoding::none)
return make_pair(false, 0);
// change encoding (not required for CJK with UTF8)
if (bparams.encoding().iconvName() != "UTF-8") {
LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
<< oldEnc.name() << " to " << newEnc.name());
os << setEncoding(newEnc.iconvName());
if (bparams.inputenc == "default")
return make_pair(true, 0);
}
docstring const inputenc_arg(from_ascii(newEnc.latexName()));
OutputState * state = getOutputState();
@ -1694,7 +1699,6 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
}
// Dead code to avoid a warning:
return make_pair(true, 0);
}
} // namespace lyx