Fix gaps between lines of selection
When a font has fractional metrics, we could get visible gaps between lines in a multi-line selection, if the bottom of the rect was not aligned to the pixel grid. In Qt 5, this was primarily an issue on macOS, but since making vertical metrics consistent in f761ad3cd9ad1252f24b76ae413298dc7bed8af3, we could also get this on other platforms, causing a regression on these platforms. The fix is to align the rect to the pixel grid. [ChangeLog][Text] Fixed an issue where there would sometimes be visible gaps in selections spanning multiple lines. Pick-to: 6.2 Fixes: QTBUG-98372 Change-Id: I03cb1465602b6d78c60a0c764d920f7f092418a8 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
56da533b45
commit
793417ce75
@ -1108,6 +1108,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QList<FormatRange>
|
||||
QRectF lineRect(tl.naturalTextRect());
|
||||
lineRect.translate(position);
|
||||
lineRect.adjust(0, 0, d->leadingSpaceWidth(sl).toReal(), 0);
|
||||
lineRect.setBottom(qCeil(lineRect.bottom()));
|
||||
|
||||
bool isLastLineInBlock = (line == d->lines.size()-1);
|
||||
int sl_length = sl.length + (isLastLineInBlock? 1 : 0); // the infamous newline
|
||||
@ -1129,6 +1130,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QList<FormatRange>
|
||||
QRectF fullLineRect(tl.rect());
|
||||
fullLineRect.translate(position);
|
||||
fullLineRect.setRight(QFIXED_MAX);
|
||||
fullLineRect.setBottom(qCeil(fullLineRect.bottom()));
|
||||
|
||||
const bool rightToLeft = d->isRightToLeft();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user