}
+namespace {
+ // Quote argument if it contains spaces
+ string quoteIfNeeded(string const & str) {
+ if (contains(str, ' '))
+ return "\"" + str + "\"";
+ return str;
+ }
+}
+
+
void BufferParams::writeFile(ostream & os, Buffer const * buf) const
{
// The top of the file is written by the buffer.
filepath.replace(0, sysdir.length(), "/systemlyxdir/");
else if (!lyxrc.save_origin)
filepath = "unavailable";
- os << "\\origin " << filepath << '\n';
+ os << "\\origin " << quoteIfNeeded(filepath) << '\n';
// the textclass
- os << "\\textclass " << buf->includedFilePath(addName(buf->layoutPos(),
- baseClass()->name()), "layout")
+ os << "\\textclass "
+ << quoteIfNeeded(buf->includedFilePath(addName(buf->layoutPos(),
+ baseClass()->name()), "layout"))
<< '\n';
// then the preamble
string format = documentClass().outputFormat();
if (format == "latex") {
if (useNonTeXFonts)
- return "xetex";
+ return "xetex"; // FIXME: why not "luatex"?
if (encoding().package() == Encoding::japanese)
return "platex";
}
void BufferParams::writeEncodingPreamble(otexstream & os,
LaTeXFeatures & features) const
{
- // XeTeX does not need this
- if (features.runparams().flavor == OutputParams::XETEX)
+ // "inputenc" package not required with non-TeX fonts.
+ if (useNonTeXFonts)
return;
- // LuaTeX neither, but with tex fonts, we need to load
- // the luainputenc package.
- if (features.runparams().flavor == OutputParams::LUATEX
- || features.runparams().flavor == OutputParams::DVILUATEX) {
- if (!useNonTeXFonts && inputenc != "default"
- && ((inputenc == "auto" && language->encoding()->package() == Encoding::inputenc)
- || (inputenc != "auto" && encoding().package() == Encoding::inputenc))) {
- os << "\\usepackage[utf8]{luainputenc}\n";
- }
+ // "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)
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 =
language->encoding()->latexName();
os << ',';
os << from_ascii(doc_encoding);
}
- os << "]{inputenc}\n";
+ if (features.runparams().flavor == OutputParams::LUATEX
+ || features.runparams().flavor == OutputParams::DVILUATEX)
+ os << "]{luainputenc}\n";
+ else
+ os << "]{inputenc}\n";
}
if (package == Encoding::CJK || features.mustProvide("CJK")) {
if (language->encoding()->name() == "utf8-cjk"
if (features.isRequired("japanese")
|| features.isProvided("inputenc"))
break;
- os << "\\usepackage[" << from_ascii(encoding().latexName())
- << "]{inputenc}\n";
+ os << "\\usepackage[" << from_ascii(encoding().latexName());
+ if (features.runparams().flavor == OutputParams::LUATEX
+ || features.runparams().flavor == OutputParams::DVILUATEX)
+ os << "]{luainputenc}\n";
+ else
+ os << "]{inputenc}\n";
break;
case Encoding::CJK:
if (encoding().name() == "utf8-cjk"
Encoding const & BufferParams::encoding() const
{
- // FIXME: actually, we should check for the flavor
- // or runparams.isFullyUnicode() here:
- // This check will not work with XeTeX/LuaTeX and tex fonts.
- // Thus we have to reset the encoding in Buffer::makeLaTeXFile
+ // FIXME: additionally, we must check for runparams().flavor == XeTeX
+ // or runparams.isFullUnicode() to care for the combination
+ // of XeTeX and TeX-fonts (see #9740).
+ // Currently, we reset the encoding in Buffer::makeLaTeXFile
// (for export) and Buffer::writeLaTeXSource (for preview).
if (useNonTeXFonts)
return *(encodings.fromLyXName("utf8-plain"));