further xetex disambiguation: use the flavor where the flavor is apt.

This introduces an isFullUnicode() function to OutputParams that currently only contains XETEX, but later can also contain other fully unicode-aware backends (LUATEX for instance).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36445 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2010-11-23 12:23:36 +00:00
parent d165b5ea51
commit fc9c1494ce
6 changed files with 23 additions and 12 deletions

View File

@ -1359,9 +1359,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
// set font encoding // set font encoding
// for arabic_arabi and farsi we also need to load the LAE and // for arabic_arabi and farsi we also need to load the LAE and
// LFE encoding // LFE encoding
// XeTeX works without fontenc // XeTeX (isFullUnicode() flavor) works without fontenc
if (font_encoding() != "default" && language->lang() != "japanese" if (font_encoding() != "default" && language->lang() != "japanese"
&& !useXetex && !tclass.provides("fontenc")) { && !features.runparams().isFullUnicode() && !tclass.provides("fontenc")) {
size_t fars = language_options.str().find("farsi"); size_t fars = language_options.str().find("farsi");
size_t arab = language_options.str().find("arabic"); size_t arab = language_options.str().find("arabic");
if (language->lang() == "arabic_arabi" if (language->lang() == "arabic_arabi"
@ -1892,7 +1892,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
// these packages (xunicode, for that matter) need to be loaded at least // these packages (xunicode, for that matter) need to be loaded at least
// after amsmath, amssymb, esint and the other packages that provide // after amsmath, amssymb, esint and the other packages that provide
// special glyphs // special glyphs
if (useXetex) { if (features.runparams().flavor == OutputParams::XETEX) {
os << "\\usepackage{xunicode}\n"; os << "\\usepackage{xunicode}\n";
texrow.newline(); texrow.newline();
os << "\\usepackage{xltxtra}\n"; os << "\\usepackage{xltxtra}\n";
@ -2456,7 +2456,8 @@ docstring BufferParams::getGraphicsDriver(string const & package) const
void BufferParams::writeEncodingPreamble(odocstream & os, void BufferParams::writeEncodingPreamble(odocstream & os,
LaTeXFeatures & features, TexRow & texrow) const LaTeXFeatures & features, TexRow & texrow) const
{ {
if (useXetex) // fully unicode-aware backends (such as XeTeX) do not need this
if (features.runparams().isFullUnicode())
return; return;
if (inputenc == "auto") { if (inputenc == "auto") {
string const doc_encoding = string const doc_encoding =

View File

@ -48,4 +48,10 @@ bool OutputParams::isLaTeX() const
return flavor == LATEX || flavor == PDFLATEX || flavor == XETEX; return flavor == LATEX || flavor == PDFLATEX || flavor == XETEX;
} }
bool OutputParams::isFullUnicode() const
{
return flavor == XETEX;
}
} // namespace lyx } // namespace lyx

View File

@ -65,6 +65,8 @@ public:
FLAVOR flavor; FLAVOR flavor;
/// is it some flavor of LaTeX? /// is it some flavor of LaTeX?
bool isLaTeX() const; bool isLaTeX() const;
/// does this flavour support full unicode?
bool isFullUnicode() const;
/// Same, but for math output, which only matter is XHTML output. /// Same, but for math output, which only matter is XHTML output.
MathFlavor math_flavor; MathFlavor math_flavor;

View File

@ -2516,7 +2516,7 @@ void Paragraph::latex(BufferParams const & bparams,
if (allowcust && d->endTeXParParams(bparams, os, texrow, runparams) if (allowcust && d->endTeXParParams(bparams, os, texrow, runparams)
&& runparams.encoding != prev_encoding) { && runparams.encoding != prev_encoding) {
runparams.encoding = prev_encoding; runparams.encoding = prev_encoding;
if (!bparams.useXetex) if (!runparams.isFullUnicode())
os << setEncoding(prev_encoding->iconvName()); os << setEncoding(prev_encoding->iconvName());
} }

View File

@ -143,11 +143,12 @@ int InsetListings::latex(odocstream & os, OutputParams const & runparams) const
bool encoding_switched = false; bool encoding_switched = false;
Encoding const * const save_enc = runparams.encoding; Encoding const * const save_enc = runparams.encoding;
if (runparams.flavor != OutputParams::XETEX if (!runparams.isFullUnicode()
&& !runparams.encoding->hasFixedWidth()) { && !runparams.encoding->hasFixedWidth()) {
// We need to switch to a singlebyte encoding, since the // We need to switch to a singlebyte encoding, since the
// listings package cannot deal with multi-byte-encoded // listings package cannot deal with multi-byte-encoded
// glyphs (not needed with XeTeX). // glyphs (not needed with full-unicode aware backends
// such as XeTeX).
Language const * const outer_language = Language const * const outer_language =
(runparams.local_font != 0) ? (runparams.local_font != 0) ?
runparams.local_font->language() runparams.local_font->language()

View File

@ -283,7 +283,7 @@ TeXEnvironment(Buffer const & buf,
prev_env_language_ = par_language; prev_env_language_ = par_language;
if (runparams.encoding != prev_encoding) { if (runparams.encoding != prev_encoding) {
runparams.encoding = prev_encoding; runparams.encoding = prev_encoding;
if (!bparams.useXetex) if (!runparams.isFullUnicode())
os << setEncoding(prev_encoding->iconvName()); os << setEncoding(prev_encoding->iconvName());
} }
} }
@ -294,7 +294,7 @@ TeXEnvironment(Buffer const & buf,
prev_env_language_ = par_language; prev_env_language_ = par_language;
if (runparams.encoding != prev_encoding) { if (runparams.encoding != prev_encoding) {
runparams.encoding = prev_encoding; runparams.encoding = prev_encoding;
if (!bparams.useXetex) if (!runparams.isFullUnicode())
os << setEncoding(prev_encoding->iconvName()); os << setEncoding(prev_encoding->iconvName());
} }
} }
@ -712,7 +712,7 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
os << '}'; os << '}';
if (runparams.encoding != prev_encoding) { if (runparams.encoding != prev_encoding) {
runparams.encoding = prev_encoding; runparams.encoding = prev_encoding;
if (!bparams.useXetex) if (!runparams.isFullUnicode())
os << setEncoding(prev_encoding->iconvName()); os << setEncoding(prev_encoding->iconvName());
} }
} }
@ -865,11 +865,12 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
// If this is the last paragraph, and a local_font was set upon entering // 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, the encoding
// should be set back to that local_font's encoding. // should be set back to that local_font's encoding.
// However, do not change the encoding when XeTeX is used. // However, do not change the encoding when a fully unicode aware backend
// such as XeTeX is used.
if (nextpit == paragraphs.end() && runparams_in.local_font != 0 if (nextpit == paragraphs.end() && 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")
&& (!bparams.useXetex)) { && (!runparams.isFullUnicode())) {
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());
} }