Handle paragraph direction switch in captions (with polyglossia/bidi)

This commit is contained in:
Juergen Spitzmueller 2019-11-19 13:37:44 +01:00
parent 70bdbd3a57
commit 1a1adbc821
3 changed files with 10 additions and 2 deletions

View File

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

View File

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

View File

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