From 098d87c63fb638db619808af8b86c043354f62c5 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 27 Jan 2017 16:41:37 +0100 Subject: 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 --- src/gui/text/qfontmetrics.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/gui/text/qfontmetrics.cpp') diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index aca59d0288..8067969f56 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -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()); -- cgit v1.2.3