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
commitf31d58049257b4853f6a0213be22f1956661e9de (patch)
tree2caeb54b705767a22167932a8637fed55a50fe5e
parentc4788c54c20ab80ab37e768180aed8badc424cce (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 61d542fbcb..8d76aa56a2 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -842,9 +842,11 @@ void QSGTextMaskMaterial::populate(const QPointF &p,
bool supportsSubPixelPositions = fontD->fontEngine->supportsSubPixelPositions();
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), subPixelPosition);
const QTextureGlyphCache::Coord &c = cache->coords.value(glyph);