diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-06-21 13:44:36 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-09-13 17:12:45 +0200 |
commit | 71fb661ef8b4329a3df39750f9c72c024ca8a060 (patch) | |
tree | b2754241a5a17cd82d10588e28c81bf766a19f2a | |
parent | fa2d761e6f5357dfb1469e9cdb81b88e8ed5bcfd (diff) |
Fix fractional scaling of text in Qt Quick
As opposed to the raster engine, in Qt Quick we are using
unscaled positions for the glyphs and using the vertex shader
to scale these after the fact. However, when picking the
correct subpixel rendering for each glyph, we would use the
unscaled position's fractional part, meaning that we
essentially rendered the glyphs at the wrong subpixel position.
This was especially visible when doing fractional scaling, e.g.
125%.
Instead, we need to ensure that we pick the rendering at the
on-screen subpixel position.
[ChangeLog][QtQuick][Text] Fixed a kerning issue with
native-rendered text when there is a fractional system scale
factor set.
Fixes: QTBUG-101008
Change-Id: Ic0f94d8b4ca5998dca638bdf7e2a16306d92a926
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 97cc7023ce8b8d903351a2e13f515592854c56fc)
-rw-r--r-- | src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index 6f3205f526..61d542fbcb 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -818,8 +818,11 @@ void QSGTextMaskMaterial::populate(const QPointF &p, QTextureGlyphCache *cache = glyphCache(); QRawFontPrivate *fontD = QRawFontPrivate::get(m_font); - cache->populate(fontD->fontEngine, glyphIndexes.size(), glyphIndexes.constData(), - fixedPointPositions.data()); + cache->populate(fontD->fontEngine, + glyphIndexes.size(), + glyphIndexes.constData(), + fixedPointPositions.data(), + true); cache->fillInPendingGlyphs(); int margin = fontD->fontEngine->glyphMargin(cache->glyphFormat()); @@ -841,7 +844,7 @@ void QSGTextMaskMaterial::populate(const QPointF &p, QPointF glyphPosition = glyphPositions.at(i) + position; QFixed subPixelPosition; if (supportsSubPixelPositions) - subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(glyphPosition.x())); + subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(glyphPosition.x() * glyphCacheScaleX)); QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphIndexes.at(i), subPixelPosition); const QTextureGlyphCache::Coord &c = cache->coords.value(glyph); |