From 04bd57a86a7aee5ee76ee461e69391f150fbe081 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 11 Jul 2019 10:31:10 +0200 Subject: [PATCH] Factor out test for bidi package (= XeTeX + polyglossia) --- src/Font.cpp | 4 ++-- src/OutputParams.cpp | 8 +++++++- src/OutputParams.h | 2 ++ src/Paragraph.cpp | 6 +++--- src/insets/InsetTabular.cpp | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Font.cpp b/src/Font.cpp index 941f94a36c..0ee6bfe9b0 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -340,7 +340,7 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams, // the numbers are written Left-to-Right. ArabTeX package // and bidi (polyglossia with XeTeX) reorder the number automatically // but the packages used for Hebrew and Farsi (Arabi) do not. - if (!(runparams.use_polyglossia && runparams.flavor == OutputParams::XETEX) + if (!runparams.useBidiPackage() && !runparams.pass_thru && bits_.number() == FONT_ON && prev.fontInfo().number() != FONT_ON @@ -507,7 +507,7 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams, // the numbers are written Left-to-Right. ArabTeX package // and bidi (polyglossia with XeTeX) reorder the number automatically // but the packages used for Hebrew and Farsi (Arabi) do not. - if (!(runparams.use_polyglossia && runparams.flavor == OutputParams::XETEX) + if (!runparams.useBidiPackage() && !runparams.pass_thru && bits_.number() == FONT_ON && next.fontInfo().number() != FONT_ON diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp index 5efe7445eb..de4b893728 100644 --- a/src/OutputParams.cpp +++ b/src/OutputParams.cpp @@ -57,7 +57,13 @@ bool OutputParams::isLaTeX() const bool OutputParams::isFullUnicode() const { - return flavor == LUATEX|| flavor == DVILUATEX || flavor == XETEX; + return flavor == LUATEX || flavor == DVILUATEX || flavor == XETEX; +} + + +bool OutputParams::useBidiPackage() const +{ + return use_polyglossia && flavor == XETEX; } } // namespace lyx diff --git a/src/OutputParams.h b/src/OutputParams.h index 3ec4eddf22..fb8cea3831 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -71,6 +71,8 @@ public: bool isLaTeX() const; /// does this flavour support full unicode? bool isFullUnicode() const; + /// Do we use the bidi package (which does some reordering and stuff)? + bool useBidiPackage() 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 5c2570431d..d129cb403e 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1861,7 +1861,7 @@ char_type Paragraph::getUChar(BufferParams const & bparams, // Return unchanged character in LTR languages // or if we use poylglossia/bidi (XeTeX). - if ((rp.use_polyglossia && rp.flavor == OutputParams::XETEX) + if (rp.useBidiPackage() || !getFontSettings(bparams, pos).isRightToLeft()) return c; @@ -2249,7 +2249,7 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams, // RTL in classic (PDF)LaTeX (without the Bidi package) // Luabibdi (used by LuaTeX) behaves like classic bool const rtl_classic = owner_->getParLanguage(bparams)->rightToLeft() - && (!runparams.use_polyglossia || runparams.flavor != OutputParams::XETEX); + && !runparams.useBidiPackage(); switch (curAlign) { case LYX_ALIGN_NONE: @@ -2313,7 +2313,7 @@ bool Paragraph::Private::endTeXParParams(BufferParams const & bparams, // RTL in classic (PDF)LaTeX (without the Bidi package) // Luabibdi (used by LuaTeX) behaves like classic bool const rtl_classic = owner_->getParLanguage(bparams)->rightToLeft() - && (!runparams.use_polyglossia || runparams.flavor != OutputParams::XETEX); + && !runparams.useBidiPackage(); switch (curAlign) { case LYX_ALIGN_NONE: diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 727018c577..334f09adff 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2934,7 +2934,7 @@ void Tabular::TeXRow(otexstream & os, row_type row, // Luabibdi (used by LuaTeX) behaves like classic bool const bidi_rtl = runparams.local_font->isRightToLeft() - && runparams.use_polyglossia && runparams.flavor == OutputParams::XETEX; + && runparams.useBidiPackage(); idx_type lastcell = bidi_rtl ? getFirstCellInRow(row) : getLastCellInRow(row); @@ -3154,7 +3154,7 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const // order for RTL (#9686). Thus we use this list. bool const bidi_rtl = runparams.local_font->isRightToLeft() - && runparams.use_polyglossia && runparams.flavor == OutputParams::XETEX; + && runparams.useBidiPackage(); list columns; for (col_type cl = 0; cl < ncols(); ++cl) { if (bidi_rtl)