From 6b1044cc3f79736b9d707d7f9f3cc8c3eae65193 Mon Sep 17 00:00:00 2001 From: Ziming Song Date: Tue, 6 Dec 2022 16:30:40 +0800 Subject: [PATCH] QTextEngine: also round x-offset for non-subpixel text render If horizontal subpixel is not supported, both glyph advance and x-offset should be rounded. Or the position of rendered glyph might be fraction number. Fixes: QTBUG-104895 Change-Id: Ia572764bb87db9712847ceea532d8d424ec7704b Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextengine.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 2dfb7f0073e..c174eefa70e 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1734,8 +1734,10 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, } if (!actualFontEngine->supportsHorizontalSubPixelPositions()) { - for (uint i = 0; i < num_glyphs; ++i) + for (uint i = 0; i < num_glyphs; ++i) { g.advances[i] = g.advances[i].round(); + g.offsets[i].x = g.offsets[i].x.round(); + } } glyphs_shaped += num_glyphs;