- // In some insets (such as Arguments), we cannot use \selectlanguage
- bool const localswitch = text.inset().forceLocalFontSwitch()
- || (using_begin_end && text.inset().forcePlainLayout());
+ // In some insets (such as Arguments), we cannot use \selectlanguage.
+ // Also, if an RTL language is set via environment in polyglossia,
+ // only a nested \\text<lang> command will reset the direction for LTR
+ // languages (see # 10111).
+ bool const in_polyglossia_rtl_env =
+ use_polyglossia
+ && runparams.local_font != nullptr
+ && outer_language->rightToLeft()
+ && !par_language->rightToLeft();
+ bool const localswitch =
+ (runparams_in.for_search
+ || text.inset().forceLocalFontSwitch()
+ || (using_begin_end && text.inset().forcePlainLayout())
+ || in_polyglossia_rtl_env)
+ && !text.inset().forceParDirectionSwitch();