aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-05-27 11:33:57 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-05-29 07:49:24 +0000
commit8a4dec618fc7e8176f1ba402a9e4d5ed342b1cf9 (patch)
tree329dd5a3fb2b502a70491571e6e68d63af18eb14 /src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
parente76629dc33953122c00e966fc41ca83a4774a881 (diff)
Fix offset on native text rendering with high-dpi scaling
The glyph positions are scaled *after* they have been positioned, so when we subtracted the margin unmodified, we would actually offset by the scaled margin (so for scale factor=2 it would be 2 pixels off, and for scale factor=4 it would be 6 pixels off, etc.) We have to also prescale the margin by the inverse of the scale we will apply later. [ChangeLog][Text] Fixed an offset on text position when combining NativeRendering with high-dpi scaling. Task-number: QTBUG-84454 Pick-to: 5.15 Change-Id: I703aeb7fbd717bee5d88cc61e9a56c6422558889 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultglyphnode_p.cpp')
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index f73b64f537..44fef4ddef 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -809,6 +809,7 @@ void QSGTextMaskMaterial::populate(const QPointF &p,
qreal glyphCacheScaleY = cache->transform().m22();
qreal glyphCacheInverseScaleX = 1.0 / glyphCacheScaleX;
qreal glyphCacheInverseScaleY = 1.0 / glyphCacheScaleY;
+ qreal scaledMargin = margin * glyphCacheInverseScaleX;
Q_ASSERT(geometry->indexType() == GL_UNSIGNED_SHORT);
geometry->allocate(glyphIndexes.size() * 4, glyphIndexes.size() * 6);
@@ -833,14 +834,14 @@ void QSGTextMaskMaterial::populate(const QPointF &p,
// apply the inverse scale to get back to the coordinate system of the node.
qreal x = (qFloor(glyphPosition.x() * glyphCacheScaleX) * glyphCacheInverseScaleX) +
- (c.baseLineX * glyphCacheInverseScaleX) - margin;
+ (c.baseLineX * glyphCacheInverseScaleX) - scaledMargin;
qreal y = (qRound(glyphPosition.y() * glyphCacheScaleY) * glyphCacheInverseScaleY) -
- (c.baseLineY * glyphCacheInverseScaleY) - margin;
+ (c.baseLineY * glyphCacheInverseScaleY) - scaledMargin;
qreal w = c.w * glyphCacheInverseScaleX;
qreal h = c.h * glyphCacheInverseScaleY;
- *boundingRect |= QRectF(x + margin, y + margin, w, h);
+ *boundingRect |= QRectF(x + scaledMargin, y + scaledMargin, w, h);
float cx1 = x - margins.left();
float cx2 = x + w + margins.right();