void BufferParams::writeEncodingPreamble(otexstream & os,
LaTeXFeatures & features) const
{
- // "inputenc" package not required with non-TeX fonts.
- if (useNonTeXFonts)
- return;
- // "inputenc" fails with XeTeX (even in 8-bit compatiblitly mode) and with TeX fonts,
- // (this is a bug in the "inputenc" package see #9740).
- if (features.runparams().flavor == OutputParams::XETEX)
+ // XeTeX/LuaTeX: (see also #9740)
+ // With Unicode fonts we use utf8-plain without encoding package.
+ // With TeX fonts, we cannot use utf8-plain, but "inputenc" fails.
+ // XeTeX must use ASCII encoding, for LuaTeX, we load
+ // "luainputenc" (see below).
+ if (useNonTeXFonts || features.runparams().flavor == OutputParams::XETEX)
return;
- // For LuaTeX with TeX fonts, we can load
- // the "luainputenc" package with the specified encoding(s) (see below).
if (inputenc == "auto") {
string const doc_encoding =
Encoding::Package const package =
language->encoding()->package();
- // Create a list with all the input encodings used
- // in the document
- set<string> encodings =
- features.getEncodingSet(doc_encoding);
+ // Create list of inputenc options:
+ set<string> encodings;
+ // luainputenc fails with more than one encoding
+ if (!features.runparams().isFullUnicode()) // if we reach this point, this means LuaTeX with TeX fonts
+ // list all input encodings used in the document
+ encodings = features.getEncodingSet(doc_encoding);
// If the "japanese" package (i.e. pLaTeX) is used,
// inputenc must be omitted.
state->prev_env_language_ = data.par_language;
if (runparams.encoding != data.prev_encoding) {
runparams.encoding = data.prev_encoding;
- if (runparams.flavor != OutputParams::XETEX) // see BufferParams::encoding
- os << setEncoding(data.prev_encoding->iconvName());
+ os << setEncoding(data.prev_encoding->iconvName());
}
}
state->prev_env_language_ = data.par_language;
if (runparams.encoding != data.prev_encoding) {
runparams.encoding = data.prev_encoding;
- if (runparams.flavor != OutputParams::XETEX) // see BufferParams::encoding
- os << setEncoding(data.prev_encoding->iconvName());
+ os << setEncoding(data.prev_encoding->iconvName());
}
}
// encoding, since this only affects the position of the outputted
// \inputencoding command; the encoding switch will occur when necessary
if (bparams.inputenc == "auto"
+ && !runparams.isFullUnicode() // Xe/LuaTeX use one document-wide encoding (see also switchEncoding())
&& runparams.encoding->package() != Encoding::none) {
// Look ahead for future encoding changes.
// We try to output them at the beginning of the paragraph,
latexArgInsets(par, os, runparams, style.postcommandargs(), "post:");
if (runparams.encoding != prev_encoding) {
runparams.encoding = prev_encoding;
- if (runparams.flavor != OutputParams::XETEX) // see BufferParams::encoding
- os << setEncoding(prev_encoding->iconvName());
+ os << setEncoding(prev_encoding->iconvName());
}
}
}
// If this is the last paragraph, and a local_font was set upon entering
- // the inset, and we're using "auto" or "default" encoding, the encoding
+ // the inset, and we're using "auto" or "default" encoding, and not
+ // compiling with XeTeX or LuaTeX, the encoding
// should be set back to that local_font's encoding.
- // However, do not change the encoding when non-TeX fonts are used.
if (runparams.isLastPar && runparams_in.local_font != 0
&& runparams_in.encoding != runparams_in.local_font->language()->encoding()
&& (bparams.inputenc == "auto" || bparams.inputenc == "default")
- && runparams.flavor != OutputParams::XETEX // see BufferParams::encoding
+ && !runparams.isFullUnicode()
) {
runparams_in.encoding = runparams_in.local_font->language()->encoding();
os << setEncoding(runparams_in.encoding->iconvName());
OutputParams const & runparams, Encoding const & newEnc,
bool force)
{
+ // XeTeX/LuaTeX use only one encoding per document:
+ // * with useNonTeXFonts: "utf8plain",
+ // * with XeTeX and TeX fonts: "ascii" (inputenc fails),
+ // * with LuaTeX and TeX fonts: only one encoding accepted by luainputenc.
+ if (runparams.isFullUnicode())
+ return make_pair(false, 0);
+
Encoding const & oldEnc = *runparams.encoding;
bool moving_arg = runparams.moving_arg;
// If we switch from/to CJK, we need to switch anyway, despite custom inputenc