aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-05-27 12:03:37 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-05-28 08:25:15 +0000
commit977c5158ae24a2d082adea624b23b1dfdd62eb79 (patch)
tree420e31a02ce7a31e84629a0b43495d1c6c5ed258 /src/quick
parentb52e81856a1d50fc331b99ae533a474a9b4e79c3 (diff)
Fix a clipping bug in software-rendered text
ac179e235ba0c01fff6dd5f4ad2cc9696fe78822 fixed a clipping issue with software rendering and text by using the actual bounding rect of the alpha map (which may be extended to allow for margins around the glyph). But it did not account for the margins on the top and left sides of the glyph, causing QTBUG-84042. By a coincidence, this issue was not reproducible with the DirectWrite engine in Qt 5.15 at the time because of 318a991907b6c08f52786160bafea1e30d3ad9bd in Qt Base, which baked the margins into the top and left positions of the returned bounding rect. But this is not what the other font engines are doing, and caused issues where the margin would be accounted for twice in the output. So 318a991907b6c08f52786160bafea1e30d3ad9bd was reverted. This change shifts the bounding rect by the margins (if any), avoiding clipping on the left and top sides. Task-number: QTBUG-80180 Fixes: QTBUG-84042 Change-Id: I942f05f0e8c8eb8c5b3071a73406e3e744b7d5a0 Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 5ce2d540be875041b38b481e3caef295071c79ee) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
index 04e9b361ca..481d1f0304 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
@@ -63,13 +63,15 @@ QRectF calculateBoundingRect(const QPointF &position, const QGlyphRun &glyphs)
QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None ? fontEngine->glyphFormat : QFontEngine::Format_A32;
+ int margin = fontEngine->glyphMargin(glyphFormat);
+
const QVector<uint> glyphIndexes = glyphs.glyphIndexes();
const QVector<QPointF> glyphPositions = glyphs.positions();
for (int i = 0, n = qMin(glyphIndexes.size(), glyphPositions.size()); i < n; ++i) {
glyph_metrics_t gm = fontEngine->alphaMapBoundingBox(glyphIndexes.at(i), QFixed(), QTransform(), glyphFormat);
- gm.x += QFixed::fromReal(glyphPositions.at(i).x());
- gm.y += QFixed::fromReal(glyphPositions.at(i).y());
+ gm.x += QFixed::fromReal(glyphPositions.at(i).x()) - margin;
+ gm.y += QFixed::fromReal(glyphPositions.at(i).y()) - margin;
if (i == 0) {
minX = gm.x;