mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Fix for CJK-documents with input-encoding "utf8".
This commit is contained in:
parent
7da76b1b9f
commit
34f5ba3c54
@ -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
|
||||
|
@ -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
|
||||
|
@ -877,7 +877,7 @@ void TeXOnePar(Buffer const & buf,
|
||||
lang_end_command = "}";
|
||||
lang_command_termination.clear();
|
||||
}
|
||||
|
||||
|
||||
bool const localswitch_needed = localswitch && par_lang != outer_lang;
|
||||
|
||||
// localswitches need to be closed and reopened at each par
|
||||
@ -890,7 +890,7 @@ void TeXOnePar(Buffer const & buf,
|
||||
if (!localswitch
|
||||
&& (!using_begin_end || langOpenedAtThisLevel(state))
|
||||
&& !lang_end_command.empty()
|
||||
&& prev_lang != outer_lang
|
||||
&& prev_lang != outer_lang
|
||||
&& !prev_lang.empty()
|
||||
&& (!using_begin_end || !style.isEnvironment())) {
|
||||
os << from_ascii(subst(lang_end_command,
|
||||
@ -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
|
||||
@ -1608,8 +1609,9 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
|
||||
// except if we use CJKutf8
|
||||
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"));
|
||||
|| (oldEnc.package() != Encoding::CJK && newEnc.package() == Encoding::CJK))
|
||||
&& ((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);
|
||||
@ -1623,17 +1625,20 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
|
||||
// This does of course only work in special cases (e.g. switch from
|
||||
// tis620-0 to latin1, but the text in latin1 contains ASCII only),
|
||||
// but it is the best we can do
|
||||
//
|
||||
//
|
||||
// 2019-01-08 Possibly no longer required since tis620-0 is supported
|
||||
// by inputenc (but check special encodings "utf8-plain" and "default").
|
||||
if (oldEnc.package() == Encoding::none || newEnc.package() == Encoding::none)
|
||||
return make_pair(false, 0);
|
||||
|
||||
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);
|
||||
// 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
|
||||
|
Loading…
Reference in New Issue
Block a user