}
+bool BufferParams::hasPackageOption(string const package, string const opt) const
+{
+ for (auto const & p : documentClass().packageOptions())
+ if (package == p.first && opt == p.second)
+ return true;
+ return false;
+}
+
+
+bool BufferParams::useBidiPackage(OutputParams const & rp) const
+{
+ return (rp.use_polyglossia
+ // as of babel 3.29, bidi=bidi-* is supported by babel
+ // So we check whether we use a respective version and
+ // whethert bidi-r or bidi-l have been requested either via class
+ // or package options
+ || (rp.use_babel
+ && LaTeXFeatures::isAvailableAtLeastFrom("babel", 2019, 4, 3)
+ && (hasPackageOption("babel", "bidi-r")
+ || hasPackageOption("babel", "bidi-l")
+ || contains(options, "bidi-r")
+ || contains(options, "bidi-l")))
+ )
+ && rp.flavor == Flavor::XeTeX;
+}
+
+
void BufferParams::readPreamble(Lexer & lex)
{
if (lex.getString() != "\\begin_preamble")
class LayoutFileIndex;
class Length;
class Lexer;
+class OutputParams;
class otexstream;
class PDFOptions;
class Spacing;
bool isLatex() const;
/// returns \c true if the buffer contains a Wed document
bool isLiterate() const;
+ /// Is this package option requested?
+ bool hasPackageOption(std::string const package, std::string const opt) const;
+ /// Do we use the bidi package (which does some reordering and stuff)?
+ bool useBidiPackage(OutputParams const & rp) const;
/// return the format of the buffer on a string
std::string bufferFormat() const;
// 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.useBidiPackage()
+ if (!bparams.useBidiPackage(runparams)
&& !runparams.pass_thru
&& bits_.number() == FONT_ON
&& prev.fontInfo().number() != FONT_ON
// 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.useBidiPackage()
+ if (!bparams.useBidiPackage(runparams)
&& !runparams.pass_thru
&& bits_.number() == FONT_ON
&& next.fontInfo().number() != FONT_ON
|| flavor == Flavor::XeTeX;
}
-
-bool OutputParams::useBidiPackage() const
-{
- return use_polyglossia && flavor == Flavor::XeTeX;
-}
-
} // namespace lyx
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 = NotApplicable;
// or if we use poylglossia/bidi (XeTeX)
// or with babel and Xe/LuaTeX.
if (!getFontSettings(bparams, pos).isRightToLeft()
- || rp.useBidiPackage()
+ || bparams.useBidiPackage(rp)
|| (rp.use_babel && rp.isFullUnicode()))
return c;
// 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.useBidiPackage();
+ && !bparams.useBidiPackage(runparams);
switch (curAlign) {
case LYX_ALIGN_NONE:
// 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.useBidiPackage();
+ && !bparams.useBidiPackage(runparams);
switch (curAlign) {
case LYX_ALIGN_NONE:
// We have to force LTR for numeric references
// [= bibliography, plain BibTeX, numeric natbib
// and biblatex]. Except for XeTeX/bidi. See #3005.
- if (rp.useBidiPackage())
+ if (buffer().masterParams().useBidiPackage(rp))
return false;
return (buffer().masterParams().citeEngine() == "basic"
|| buffer().masterParams().citeEngineType() == ENGINE_TYPE_NUMERICAL);
// * Parentheses are automatically swapped with XeTeX/bidi
// [not with LuaTeX/luabidi] (see #11626).
// FIXME: Re-Audit all other RTL cases.
- if (rp.useBidiPackage())
+ if (buffer().masterParams().useBidiPackage(rp))
return false;
return (getCmdName() != "nameref" || !buffer().masterParams().useNonTeXFonts);
}
// Luabibdi (used by LuaTeX) behaves like classic
bool const bidi_rtl =
runparams.local_font->isRightToLeft()
- && runparams.useBidiPackage();
+ && buffer().params().useBidiPackage(runparams);
bool const ct = !buffer().params().output_changes;
idx_type lastcell =
bidi_rtl ? getFirstCellInRow(row, ct) : getLastCellInRow(row, ct);
// order for RTL (#9686). Thus we use this list.
bool const bidi_rtl =
runparams.local_font->isRightToLeft()
- && runparams.useBidiPackage();
+ && buffer().params().useBidiPackage(runparams);
list<col_type> columns;
list<col_type> logical_columns;
for (col_type cl = 0; cl < ncols(); ++cl) {