diff --git a/src/Row.cpp b/src/Row.cpp index e3e8a3430a..5bdcbe004b 100644 --- a/src/Row.cpp +++ b/src/Row.cpp @@ -259,6 +259,35 @@ ostream & operator<<(ostream & os, Row const & row) } +int Row::left_x() const +{ + double x = left_margin; + const_iterator const end = elements_.end(); + const_iterator cit = elements_.begin(); + while (cit != end && cit->isVirtual()) { + x += cit->full_width(); + ++cit; + } + return int(x + 0.5); +} + + +int Row::right_x() const +{ + double x = dim_.wid; + const_iterator const begin = elements_.begin(); + const_iterator cit = elements_.end(); + while (cit != begin) { + --cit; + if (cit->isVirtual()) + x -= cit->full_width(); + else + break; + } + return int(x + 0.5); +} + + int Row::countSeparators() const { int n = 0; diff --git a/src/Row.h b/src/Row.h index a51e3ceb91..e03e4c9e9d 100644 --- a/src/Row.h +++ b/src/Row.h @@ -170,6 +170,11 @@ public: /// int descent() const { return dim_.des; } + /// The offset of the left-most cursor position on the row + int left_x() const; + /// The offset of the right-most cursor position on the row + int right_x() const; + // Return the number of separators in the row int countSeparators() const; // Set the extra spacing for every separator in STRING elements diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 15ecafe46c..73bd4f8baa 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -1956,8 +1956,8 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const rp.paintLast(); if (i == 0 && is_rtl) rp.paintFirst(); - rp.paintTooLargeMarks(row_x < 0, - row_x + row.width() > bv_->workWidth()); + rp.paintTooLargeMarks(row_x < row.left_x(), + row_x + row.right_x() > bv_->workWidth()); y += row.descent(); // Restore full_repaint status.