Fix clipping error on some RTL text

There was a false assumption that the bidi level of text is only
used for visualizing the text, not for calculating its bounding
box. But the bidi level is required for shaping (indeed many
OpenType rules check for reading direction) and the glyphs used
to represent a given text may be different based on its
directionality. The effect would be that the bounding rect we
calculated for text would sometimes be too small for RTL text, and
we would end up clipping pixels.

[ChangeLog][QtGui][Text] Fixed clipping errors and too small
bounding rects for some right-to-left text.

Task-number: QTBUG-48005
Change-Id: Idd12ae1b0033d518034b582204ba47ae41795293
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2017-01-27 16:41:37 +01:00
parent 39fb26376c
commit 098d87c63f
2 changed files with 0 additions and 7 deletions

View File

@ -7570,7 +7570,6 @@ start_lengthVariant:
lineWidth = qMax<qreal>(0, r.width());
if(!wordwrap)
tf |= Qt::TextIncludeTrailingSpaces;
textLayout.engine()->ignoreBidi = bool(tf & Qt::TextDontPrint);
textLayout.beginLayout();
qreal leading = fm.leading();

View File

@ -556,7 +556,6 @@ int QFontMetrics::width(const QString &text, int len, int flags) const
}
QStackTextEngine layout(text, QFont(d.data()));
layout.ignoreBidi = true;
return qRound(layout.width(0, len));
}
@ -692,7 +691,6 @@ QRect QFontMetrics::boundingRect(const QString &text) const
return QRect();
QStackTextEngine layout(text, QFont(d.data()));
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.boundingBox(0, text.length());
return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
@ -861,7 +859,6 @@ QRect QFontMetrics::tightBoundingRect(const QString &text) const
return QRect();
QStackTextEngine layout(text, QFont(d.data()));
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.tightBoundingBox(0, text.length());
return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
@ -1413,7 +1410,6 @@ qreal QFontMetricsF::width(const QString &text) const
int len = (pos != -1) ? pos : text.length();
QStackTextEngine layout(text, QFont(d.data()));
layout.ignoreBidi = true;
layout.itemize();
return layout.width(0, len).toReal();
}
@ -1496,7 +1492,6 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const
return QRectF();
QStackTextEngine layout(text, QFont(d.data()));
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.boundingBox(0, len);
return QRectF(gm.x.toReal(), gm.y.toReal(),
@ -1668,7 +1663,6 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const
return QRect();
QStackTextEngine layout(text, QFont(d.data()));
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.tightBoundingBox(0, text.length());
return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());