[LyX/master] Handle paragraph direction switch in captions (with polyglossia/bidi)

Juergen Spitzmueller spitz at lyx.org
Tue Nov 19 12:31:03 UTC 2019


commit 1a1adbc821e7386d5bd2dc58089c6a99749f3d54
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Tue Nov 19 13:37:44 2019 +0100

    Handle paragraph direction switch in captions (with polyglossia/bidi)
---
 src/insets/Inset.h      |    4 ++++
 src/insets/InsetFloat.h |    2 ++
 src/output_latex.cpp    |    6 ++++--
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index f458121..3f7178f 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -423,6 +423,10 @@ public:
 	/// if this inset has paragraphs should they be forced to use a
 	/// local font language switch?
 	virtual bool forceLocalFontSwitch() const { return false; }
+	/// if this inset has paragraphs should they be forced to use a
+	/// font language switch that switches paragraph directions
+	/// (relevant with polyglossia only)?
+	virtual bool forceParDirectionSwitch() const { return false; }
 	/// Does the inset force a specific encoding?
 	virtual Encoding const * forcedEncoding(Encoding const *, Encoding const *) const
 	{ return 0; }
diff --git a/src/insets/InsetFloat.h b/src/insets/InsetFloat.h
index 224017e..734ba51 100644
--- a/src/insets/InsetFloat.h
+++ b/src/insets/InsetFloat.h
@@ -76,6 +76,8 @@ public:
 	bool allowsCaptionVariation(std::string const &) const;
 	///
 	LyXAlignment contentAlignment() const;
+	///
+	bool forceParDirectionSwitch() const { return true; }
 private:
 	///
 	void setCaptionType(std::string const & type);
diff --git a/src/output_latex.cpp b/src/output_latex.cpp
index 4124d2d..a349cbd 100644
--- a/src/output_latex.cpp
+++ b/src/output_latex.cpp
@@ -913,10 +913,12 @@ void TeXOnePar(Buffer const & buf,
 		&& runparams.local_font != nullptr
 		&& outer_language->rightToLeft()
 		&& !par_language->rightToLeft();
-	bool const localswitch = runparams_in.for_search
+	bool const localswitch =
+			(runparams_in.for_search
 			|| text.inset().forceLocalFontSwitch()
 			|| (using_begin_end && text.inset().forcePlainLayout())
-			|| in_polyglossia_rtl_env;
+			|| in_polyglossia_rtl_env)
+			&& !text.inset().forceParDirectionSwitch();
 	if (localswitch) {
 		lang_begin_command = use_polyglossia ?
 			    "\\text$$lang$$opts{" : lyxrc.language_command_local;


More information about the lyx-cvs mailing list