aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-09-28 01:00:06 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-09-28 01:00:06 +0200
commitfb7d79e3303b6338995acc0b21bfb8a1b4e5b27a (patch)
treee68f4f53da4ad8f4a05a4bdb885acf4818fec6f2 /src/quick/scenegraph
parent7f0804a86ffd597ff5c43bf779a6c81c23a9f860 (diff)
parent10356e7d5aa3fdb12b01239498ccc0c1cdf5a721 (diff)
Merge remote-tracking branch 'origin/5.12' into dev
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
index 7ab9c15d9b..dd789b78c7 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
@@ -49,12 +49,40 @@ QSGSoftwareGlyphNode::QSGSoftwareGlyphNode()
setGeometry(&m_geometry);
}
+namespace {
+QRectF calculateBoundingRect(const QPointF &position, const QGlyphRun &glyphs)
+{
+ qreal minX = 0;
+ qreal minY = 0;
+ qreal maxX = 0;
+ qreal maxY = 0;
+
+ for (int i = 0, n = qMin(glyphs.glyphIndexes().size(), glyphs.positions().size()); i < n; ++i) {
+ QRectF glyphRect = glyphs.rawFont().boundingRect(glyphs.glyphIndexes()[i]);
+ glyphRect.translate(glyphs.positions()[i]);
+
+ if (i == 0) {
+ minX = glyphRect.left();
+ minY = glyphRect.top();
+ maxX = glyphRect.right();
+ maxY = glyphRect.bottom();
+ } else {
+ minX = qMin(glyphRect.left(), minX);
+ minY = qMin(glyphRect.top(), minY);
+ maxX = qMax(glyphRect.right(),maxX);
+ maxY = qMax(glyphRect.bottom(), maxY);
+ }
+ }
+ QRectF boundingRect(QPointF(minX, minY), QPointF(maxX, maxY));
+ return boundingRect.translated(position - QPointF(0.0, glyphs.rawFont().ascent()));
+}
+}
void QSGSoftwareGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &glyphs)
{
m_position = position;
m_glyphRun = glyphs;
- m_bounding_rect = glyphs.boundingRect().translated(m_position - QPointF(0.0, glyphs.rawFont().ascent()));
+ m_bounding_rect = calculateBoundingRect(position, glyphs);
}
void QSGSoftwareGlyphNode::setColor(const QColor &color)