Factor out test for bidi package (= XeTeX + polyglossia)

This commit is contained in:
Juergen Spitzmueller 2019-07-11 10:31:10 +02:00
parent 1d0929b5d9
commit 04bd57a86a
5 changed files with 16 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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:

View File

@ -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<col_type> columns;
for (col_type cl = 0; cl < ncols(); ++cl) {
if (bidi_rtl)