diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-09-28 01:00:06 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-09-28 01:00:06 +0200 |
commit | fb7d79e3303b6338995acc0b21bfb8a1b4e5b27a (patch) | |
tree | e68f4f53da4ad8f4a05a4bdb885acf4818fec6f2 /src/quick/scenegraph | |
parent | 7f0804a86ffd597ff5c43bf779a6c81c23a9f860 (diff) | |
parent | 10356e7d5aa3fdb12b01239498ccc0c1cdf5a721 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: Ib3a86d40b697a919b1c55981c7954d0b0d9b8c8e
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r-- | src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp | 30 |
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) |