From fc9c1494ce9879ad2a59daa629fefb2086cf34db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 23 Nov 2010 12:23:36 +0000 Subject: [PATCH] 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 --- src/BufferParams.cpp | 9 +++++---- src/OutputParams.cpp | 6 ++++++ src/OutputParams.h | 2 ++ src/Paragraph.cpp | 2 +- src/insets/InsetListings.cpp | 5 +++-- src/output_latex.cpp | 11 ++++++----- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index b5254822b1..66df42b545 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1359,9 +1359,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, // set font encoding // for arabic_arabi and farsi we also need to load the LAE and // LFE encoding - // XeTeX works without fontenc + // XeTeX (isFullUnicode() flavor) works without fontenc 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 arab = language_options.str().find("arabic"); 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 // after amsmath, amssymb, esint and the other packages that provide // special glyphs - if (useXetex) { + if (features.runparams().flavor == OutputParams::XETEX) { os << "\\usepackage{xunicode}\n"; texrow.newline(); os << "\\usepackage{xltxtra}\n"; @@ -2456,7 +2456,8 @@ docstring BufferParams::getGraphicsDriver(string const & package) const void BufferParams::writeEncodingPreamble(odocstream & os, LaTeXFeatures & features, TexRow & texrow) const { - if (useXetex) + // fully unicode-aware backends (such as XeTeX) do not need this + if (features.runparams().isFullUnicode()) return; if (inputenc == "auto") { string const doc_encoding = diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp index b575a2915a..44eec4b89f 100644 --- a/src/OutputParams.cpp +++ b/src/OutputParams.cpp @@ -48,4 +48,10 @@ bool OutputParams::isLaTeX() const return flavor == LATEX || flavor == PDFLATEX || flavor == XETEX; } + +bool OutputParams::isFullUnicode() const +{ + return flavor == XETEX; +} + } // namespace lyx diff --git a/src/OutputParams.h b/src/OutputParams.h index 6653a41a0f..2cd9694463 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -65,6 +65,8 @@ public: FLAVOR flavor; /// is it some flavor of LaTeX? bool isLaTeX() const; + /// does this flavour support full unicode? + bool isFullUnicode() const; /// Same, but for math output, which only matter is XHTML output. MathFlavor math_flavor; diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 19caf37546..8845054b0c 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -2516,7 +2516,7 @@ void Paragraph::latex(BufferParams const & bparams, if (allowcust && d->endTeXParParams(bparams, os, texrow, runparams) && runparams.encoding != prev_encoding) { runparams.encoding = prev_encoding; - if (!bparams.useXetex) + if (!runparams.isFullUnicode()) os << setEncoding(prev_encoding->iconvName()); } diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index 8276f4301b..ad274434d7 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -143,11 +143,12 @@ int InsetListings::latex(odocstream & os, OutputParams const & runparams) const bool encoding_switched = false; Encoding const * const save_enc = runparams.encoding; - if (runparams.flavor != OutputParams::XETEX + if (!runparams.isFullUnicode() && !runparams.encoding->hasFixedWidth()) { // We need to switch to a singlebyte encoding, since the // 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 = (runparams.local_font != 0) ? runparams.local_font->language() diff --git a/src/output_latex.cpp b/src/output_latex.cpp index c52cff0878..a2013706df 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -283,7 +283,7 @@ TeXEnvironment(Buffer const & buf, prev_env_language_ = par_language; if (runparams.encoding != prev_encoding) { runparams.encoding = prev_encoding; - if (!bparams.useXetex) + if (!runparams.isFullUnicode()) os << setEncoding(prev_encoding->iconvName()); } } @@ -294,7 +294,7 @@ TeXEnvironment(Buffer const & buf, prev_env_language_ = par_language; if (runparams.encoding != prev_encoding) { runparams.encoding = prev_encoding; - if (!bparams.useXetex) + if (!runparams.isFullUnicode()) os << setEncoding(prev_encoding->iconvName()); } } @@ -712,7 +712,7 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf, os << '}'; if (runparams.encoding != prev_encoding) { runparams.encoding = prev_encoding; - if (!bparams.useXetex) + if (!runparams.isFullUnicode()) 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 // the inset, and we're using "auto" or "default" encoding, the 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 && runparams_in.encoding != runparams_in.local_font->language()->encoding() && (bparams.inputenc == "auto" || bparams.inputenc == "default") - && (!bparams.useXetex)) { + && (!runparams.isFullUnicode())) { runparams_in.encoding = runparams_in.local_font->language()->encoding(); os << setEncoding(runparams_in.encoding->iconvName()); }