summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2017-01-27 16:41:37 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2017-01-31 13:45:08 +0000
commit098d87c63fb638db619808af8b86c043354f62c5 (patch)
treefac6665aa5697853694d32e1b8f17bed692d28ef /src
parent39fb26376c9718a8d09180c5947c2efec0d01adc (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qpainter.cpp1
-rw-r--r--src/gui/text/qfontmetrics.cpp6
2 files changed, 0 insertions, 7 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 74b961f042..083e68fcdb 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -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();
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());