From b469c142ad579d3338fc81ab3e1c6ee7b4e270ec Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 16 May 2024 14:56:28 +0200 Subject: [PATCH] Fix display of math hull inset in RTL context The inversion of margin was done in the wrong way for RTL support. --- src/TextMetrics.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index ce8cfe552d..fe8aa4d73a 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -2050,8 +2050,14 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const size_t const nrows = pm.rows().size(); int const wh = bv_->workHeight(); // Remember left and right margin for drawing math numbers - Changer changeleft = changeVar(pi.leftx, x + leftMargin(pit)); - Changer changeright = changeVar(pi.rightx, x + width() - rightMargin(pit)); + Changer changeleft, changeright; + if (text_->isRTL(pit)) { + changeleft = changeVar(pi.leftx, x + rightMargin(pit)); + changeright = changeVar(pi.rightx, x + width() - leftMargin(pit)); + } else { + changeleft = changeVar(pi.leftx, x + leftMargin(pit)); + changeright = changeVar(pi.rightx, x + width() - rightMargin(pit)); + } // Use fast lane in nodraw stage. if (pi.pain.isNull()) { @@ -2100,9 +2106,6 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const } } - if (text_->isRTL(pit)) - swap(pi.leftx, pi.rightx); - BookmarksSection::BookmarkPosList bpl = theSession().bookmarks().bookmarksInPar(bv_->buffer().fileName(), pm.id()); -- 2.39.5