Fix text direction of references with XeTeX/bidi

Fixes: #11626
This commit is contained in:
Juergen Spitzmueller 2019-08-05 16:30:01 +02:00
parent 8acbcebf11
commit 231b36d950
10 changed files with 17 additions and 12 deletions

View File

@ -1005,7 +1005,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
bool close = false; bool close = false;
odocstream::pos_type const len = os.os().tellp(); odocstream::pos_type const len = os.os().tellp();
if (inset->forceLTR() if (inset->forceLTR(runparams)
&& running_font.isRightToLeft() && running_font.isRightToLeft()
// ERT is an exception, it should be output with no // ERT is an exception, it should be output with no
// decorations at all // decorations at all

View File

@ -246,7 +246,7 @@ bool Inset::allowEmpty() const
} }
bool Inset::forceLTR() const bool Inset::forceLTR(OutputParams const &) const
{ {
return getLayout().forceLTR(); return getLayout().forceLTR();
} }

View File

@ -242,7 +242,7 @@ public:
/// Don't eliminate empty paragraphs /// Don't eliminate empty paragraphs
virtual bool allowEmpty() const; virtual bool allowEmpty() const;
/// Force inset into LTR environment if surroundings are RTL /// Force inset into LTR environment if surroundings are RTL
virtual bool forceLTR() const; virtual bool forceLTR(OutputParams const &) const;
/// whether to include this inset in the strings generated for the TOC /// whether to include this inset in the strings generated for the TOC
virtual bool isInToc() const; virtual bool isInToc() const;

View File

@ -110,7 +110,7 @@ private:
/// ///
std::string contextMenuName() const; std::string contextMenuName() const;
/// Force inset into LTR environment if surroundings are RTL /// Force inset into LTR environment if surroundings are RTL
bool forceLTR() const { return true; } bool forceLTR(OutputParams const &) const { return true; }
/// ///
void doDispatch(Cursor & cur, FuncRequest & cmd); void doDispatch(Cursor & cur, FuncRequest & cmd);
/// ///

View File

@ -32,7 +32,7 @@ public:
/// ///
bool hasSettings() const { return true; } bool hasSettings() const { return true; }
/// ///
bool forceLTR() const { return true; } bool forceLTR(OutputParams const &) const { return true; }
/// ///
bool isInToc() const { return true; } bool isInToc() const { return true; }
/// ///

View File

@ -743,7 +743,7 @@ void InsetInfo::setText(docstring const & str, Language const * lang)
} }
bool InsetInfo::forceLTR() const bool InsetInfo::forceLTR(OutputParams const &) const
{ {
return params_.force_ltr; return params_.force_ltr;
} }

View File

@ -196,7 +196,7 @@ public:
/// ///
void doDispatch(Cursor & cur, FuncRequest & cmd); void doDispatch(Cursor & cur, FuncRequest & cmd);
/// Force inset into LTR environment if surroundings are RTL /// Force inset into LTR environment if surroundings are RTL
bool forceLTR() const; bool forceLTR(OutputParams const &) const;
/// ///
void setInfo(std::string const & info); void setInfo(std::string const & info);
/// ///

View File

@ -471,11 +471,16 @@ void InsetRef::validate(LaTeXFeatures & features) const
features.require("nameref"); features.require("nameref");
} }
bool InsetRef::forceLTR() const bool InsetRef::forceLTR(OutputParams const & rp) const
{ {
// We force LTR for references. Namerefs are output in the scripts direction // We force LTR for references. However,
// at least with fontspec/bidi, though (see #11518). // * Namerefs are output in the scripts direction
// at least with fontspec/bidi and luabidi, though (see #11518).
// * Parentheses are automatically swapped with XeTeX/bidi
// [not with LuaTeX/luabidi] (see #11626).
// FIXME: Re-Audit all other RTL cases. // FIXME: Re-Audit all other RTL cases.
if (rp.useBidiPackage())
return false;
return (getCmdName() != "nameref" || !buffer().masterParams().useNonTeXFonts); return (getCmdName() != "nameref" || !buffer().masterParams().useNonTeXFonts);
} }

View File

@ -73,7 +73,7 @@ public:
void addToToc(DocIterator const & di, bool output_active, void addToToc(DocIterator const & di, bool output_active,
UpdateType utype, TocBackend & backend) const; UpdateType utype, TocBackend & backend) const;
/// ///
bool forceLTR() const; bool forceLTR(OutputParams const &) const;
//@} //@}
/// \name Static public methods obligated for InsetCommand derived classes /// \name Static public methods obligated for InsetCommand derived classes

View File

@ -172,7 +172,7 @@ public:
void initUnicodeMath() const; void initUnicodeMath() const;
/// Force inset into LTR environment if surroundings are RTL /// Force inset into LTR environment if surroundings are RTL
virtual bool forceLTR() const { return true; } virtual bool forceLTR(OutputParams const &) const { return true; }
/// ///
void recordLocation(DocIterator const & di); void recordLocation(DocIterator const & di);