aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-12-19 10:05:33 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-12-20 09:23:49 +0000
commit413b4d1dc1daa6555842c892b318fe32080cdff8 (patch)
tree8d60651454099addcd4a7d9acf8737cf08bc4932
parent7e7f24a8b7c7ce12d35312480c09cbe404dbfe8b (diff)
Fix missing glyphs when using NativeRendering
When we look up glyphs with subpixel positions in the glyph cache, we use the calculated subpixel position (from a set of predefined subpixel positions) as key. In some very rare cases, we could end up with different subpixel positions when looking up an on-screen position than when we entered it into the cache, due to numerical differences when doing the calculation. The reason for this was that when entering the glyph into the cache, we used the 16.6 fixed point representation, whereas when looking up, we used the unmodified float. In some cases, the converted fixed point approximation might snap to a different predefined subpixel position than the floating point equivalent. To avoid this, we reuse the converted fixed point positions when looking up the glyphs in the cache. [ChangeLog][Text] Fixed an issue where text using NativeRendering would sometimes be missing glyphs. Fixes: QTBUG-108713 Change-Id: Iecc264eb3d27e875c24257eaefcfb18a1a5fb5be Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars@knoll.priv.no> (cherry picked from commit 4bad329985b75090c68a70cceee7edadc172d7ab) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index bc34bc063b..a57a5b40e4 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -508,9 +508,11 @@ void QSGTextMaskMaterial::populate(const QPointF &p,
bool supportsSubPixelPositions = fontD->fontEngine->supportsHorizontalSubPixelPositions();
for (int i=0; i<glyphIndexes.size(); ++i) {
QPointF glyphPosition = glyphPositions.at(i) + position;
+ QFixedPoint fixedPointPosition = fixedPointPositions.at(i);
+
QFixed subPixelPosition;
if (supportsSubPixelPositions)
- subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(glyphPosition.x() * glyphCacheScaleX));
+ subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(fixedPointPosition.x.toReal() * glyphCacheScaleX));
QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphIndexes.at(i),
QFixedPoint(subPixelPosition, 0));