From 7c0d9eb4d9361b519e7e2bcc98b9759e7ce31d3e Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 5 Aug 2019 16:30:01 +0200 Subject: [PATCH] Fix text direction of references with XeTeX/bidi Fixes: #11626 (cherry picked from commit 231b36d95011f99993684add6e0cdd6012ec13d4) --- src/Paragraph.cpp | 2 +- src/insets/Inset.cpp | 2 +- src/insets/Inset.h | 2 +- src/insets/InsetGraphics.h | 2 +- src/insets/InsetHyperlink.h | 2 +- src/insets/InsetInfo.cpp | 2 +- src/insets/InsetInfo.h | 2 +- src/insets/InsetRef.cpp | 11 ++++++++--- src/insets/InsetRef.h | 2 +- src/mathed/InsetMathHull.h | 2 +- status.23x | 2 ++ 11 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index d95c531387..6718bf35db 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1089,7 +1089,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams, bool close = false; odocstream::pos_type const len = os.os().tellp(); - if (inset->forceLTR() + if (inset->forceLTR(runparams) && running_font.isRightToLeft() // ERT is an exception, it should be output with no // decorations at all diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index 0257ed0c45..3ab5f33bc4 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -246,7 +246,7 @@ bool Inset::allowEmpty() const } -bool Inset::forceLTR() const +bool Inset::forceLTR(OutputParams const &) const { return getLayout().forceLTR(); } diff --git a/src/insets/Inset.h b/src/insets/Inset.h index fe58cd434e..a1c0518a2c 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -237,7 +237,7 @@ public: /// Don't eliminate empty paragraphs virtual bool allowEmpty() const; /// 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 virtual bool isInToc() const; diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h index 27f9cf1caf..28ea337246 100644 --- a/src/insets/InsetGraphics.h +++ b/src/insets/InsetGraphics.h @@ -106,7 +106,7 @@ private: /// std::string contextMenuName() const; /// 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); /// diff --git a/src/insets/InsetHyperlink.h b/src/insets/InsetHyperlink.h index a70200cc75..d5da130d76 100644 --- a/src/insets/InsetHyperlink.h +++ b/src/insets/InsetHyperlink.h @@ -32,7 +32,7 @@ public: /// bool hasSettings() const { return true; } /// - bool forceLTR() const { return true; } + bool forceLTR(OutputParams const &) const { return true; } /// bool isInToc() const { return true; } /// diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 13dd240f13..a3b83428d3 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -297,7 +297,7 @@ void InsetInfo::setText(docstring const & str) } -bool InsetInfo::forceLTR() const +bool InsetInfo::forceLTR(OutputParams const &) const { return !buffer().params().language->rightToLeft() || force_ltr_; } diff --git a/src/insets/InsetInfo.h b/src/insets/InsetInfo.h index 36b224e566..57549e3382 100644 --- a/src/insets/InsetInfo.h +++ b/src/insets/InsetInfo.h @@ -126,7 +126,7 @@ public: /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// Force inset into LTR environment if surroundings are RTL - bool forceLTR() const; + bool forceLTR(OutputParams const &) const; /// void setInfo(std::string const & info); /// update info_ and text diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index d5901d505a..0b9669d01a 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -471,11 +471,16 @@ void InsetRef::validate(LaTeXFeatures & features) const 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 - // at least with fontspec/bidi, though (see #11518). + // We force LTR for references. However, + // * 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. + if (rp.use_polyglossia && rp.flavor == OutputParams::XETEX) + return false; return (getCmdName() != "nameref" || !buffer().masterParams().useNonTeXFonts); } diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index 3e3e7b07d9..c1860e1a4c 100644 --- a/src/insets/InsetRef.h +++ b/src/insets/InsetRef.h @@ -73,7 +73,7 @@ public: void addToToc(DocIterator const & di, bool output_active, UpdateType utype, TocBackend & backend) const; /// - bool forceLTR() const; + bool forceLTR(OutputParams const &) const; //@} /// \name Static public methods obligated for InsetCommand derived classes diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index 6f9f90873c..132003a6fb 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -179,7 +179,7 @@ public: static int displayMargin() { return 12; } /// 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); diff --git a/status.23x b/status.23x index cc615f005f..a4d3324dd5 100644 --- a/status.23x +++ b/status.23x @@ -83,6 +83,8 @@ What's new - Fix direction of roman numbers with RTL documents and LuaTeX. +- Fix direction of references with XeTeX/bidi (bug 11626). + * USER INTERFACE -- 2.39.5