Reset encoding after insets and environments also for LuaTeX with TeX fonts.

With inputenc == "auto" or "default", the encoding changes with
the language and must be reset after an eventual language switch in insets
or environments (see #6216).

However, whether we need to do this does not depend on 8-bit TeX vs. LuaTeX
but on the possible use of more than one encoding for the document.
With "nonTeXFonts", the encoding is utf8,
LuaTeX with TeX fonts requires encoding handling similar to 8-bit TeX.

(Additionally, the value of "params.inputenc" could be tested: if it is
not "auto" or "default", we have just one common encoding and could skip
the reset as well.) Not sure how much time this saves, though.
This commit is contained in:
Günter Milde 2015-11-09 11:45:01 +01:00
parent b71991f0cc
commit 480937a103
2 changed files with 6 additions and 5 deletions

View File

@ -2567,7 +2567,7 @@ void Paragraph::latex(BufferParams const & bparams,
if (allowcust && d->endTeXParParams(bparams, os, runparams) if (allowcust && d->endTeXParParams(bparams, os, runparams)
&& runparams.encoding != prev_encoding) { && runparams.encoding != prev_encoding) {
runparams.encoding = prev_encoding; runparams.encoding = prev_encoding;
if (!runparams.isFullUnicode()) // FIXME: test for UseTeXFonts if (!bparams.useNonTeXFonts)
os << setEncoding(prev_encoding->iconvName()); os << setEncoding(prev_encoding->iconvName());
} }

View File

@ -235,6 +235,7 @@ static void finishEnvironment(otexstream & os, OutputParams const & runparams,
TeXEnvironmentData const & data) TeXEnvironmentData const & data)
{ {
OutputState * state = getOutputState(); OutputState * state = getOutputState();
// BufferParams const & bparams = buf.params(); // FIXME: for speedup shortcut below, would require passing of "buf" as argument
if (state->open_encoding_ == CJK && data.cjk_nested) { if (state->open_encoding_ == CJK && data.cjk_nested) {
// We need to close the encoding even if it does not change // We need to close the encoding even if it does not change
// to do correct environment nesting // to do correct environment nesting
@ -248,7 +249,7 @@ static void finishEnvironment(otexstream & os, OutputParams const & runparams,
state->prev_env_language_ = data.par_language; state->prev_env_language_ = data.par_language;
if (runparams.encoding != data.prev_encoding) { if (runparams.encoding != data.prev_encoding) {
runparams.encoding = data.prev_encoding; runparams.encoding = data.prev_encoding;
if (!runparams.isFullUnicode()) // FIXME: test for UseTeXFonts //if (!bparams.useNonTeXFonts) // FIXME just for speedup, would require passing of "buf" as argument
os << setEncoding(data.prev_encoding->iconvName()); os << setEncoding(data.prev_encoding->iconvName());
} }
} }
@ -258,7 +259,7 @@ static void finishEnvironment(otexstream & os, OutputParams const & runparams,
state->prev_env_language_ = data.par_language; state->prev_env_language_ = data.par_language;
if (runparams.encoding != data.prev_encoding) { if (runparams.encoding != data.prev_encoding) {
runparams.encoding = data.prev_encoding; runparams.encoding = data.prev_encoding;
if (!runparams.isFullUnicode()) // FIXME: test for UseTeXFonts //if (!bparams.useNonTeXFonts) //FIXME just for speedup
os << setEncoding(data.prev_encoding->iconvName()); os << setEncoding(data.prev_encoding->iconvName());
} }
} }
@ -883,7 +884,7 @@ void TeXOnePar(Buffer const & buf,
latexArgInsets(par, os, runparams, style.postcommandargs(), "post:"); latexArgInsets(par, os, runparams, style.postcommandargs(), "post:");
if (runparams.encoding != prev_encoding) { if (runparams.encoding != prev_encoding) {
runparams.encoding = prev_encoding; runparams.encoding = prev_encoding;
if (!runparams.isFullUnicode()) // FIXME: test for UseTeXFonts if (!bparams.useNonTeXFonts)
os << setEncoding(prev_encoding->iconvName()); os << setEncoding(prev_encoding->iconvName());
} }
} }
@ -1048,7 +1049,7 @@ void TeXOnePar(Buffer const & buf,
if (runparams.isLastPar && runparams_in.local_font != 0 if (runparams.isLastPar && runparams_in.local_font != 0
&& runparams_in.encoding != runparams_in.local_font->language()->encoding() && runparams_in.encoding != runparams_in.local_font->language()->encoding()
&& (bparams.inputenc == "auto" || bparams.inputenc == "default") && (bparams.inputenc == "auto" || bparams.inputenc == "default")
&& (!runparams.isFullUnicode())) { // FIXME: test for UseTeXFonts && !bparams.useNonTeXFonts) {
runparams_in.encoding = runparams_in.local_font->language()->encoding(); runparams_in.encoding = runparams_in.local_font->language()->encoding();
os << setEncoding(runparams_in.encoding->iconvName()); os << setEncoding(runparams_in.encoding->iconvName());
} }