From bda75c81f5648a4f1f2d15b4efaf38a03d5f0d64 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 30 Nov 2021 13:02:18 +0100 Subject: Fix missing characters or assert with certain font sizes The alphaMapBoundingBox() only exists to prefetch the size of rendered alpha maps, to reserve space in the glyph cache. Since 104e6d0f5427f5ebaab106b1651eb76c4c56df98 we have not used the QPainterPath fallback code path when actually rendering the glyphs, but that patch neglected to update the code that retrieved the bounding box. This could in some cases cause a mismatch, and if the alpha map we ended up with in the end was larger than the reserved space, this could trigger an assert or an empty spot in the cache. [ChangeLog][Text][Freetype] Fixed an issue where characters would in some rare cases be missing from text, depending on font metrics, font size and system scale factor. Pick-to: 5.15 6.2 Fixes: QTBUG-86633 Change-Id: Ic8ade168115e4f51bac71539325936bbae993120 Reviewed-by: Konstantin Ritt Reviewed-by: Lars Knoll --- src/gui/text/freetype/qfontengine_ft.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/text/freetype/qfontengine_ft.cpp b/src/gui/text/freetype/qfontengine_ft.cpp index 848267a245..35e861d430 100644 --- a/src/gui/text/freetype/qfontengine_ft.cpp +++ b/src/gui/text/freetype/qfontengine_ft.cpp @@ -1788,7 +1788,10 @@ glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, const QTransform &matrix, QFontEngine::GlyphFormat format) { - Glyph *g = loadGlyphFor(glyph, subPixelPosition, format, matrix, true); + // When rendering glyphs into a cache via the alphaMap* functions, we disable + // outline drawing. To ensure the bounding box matches the rendered glyph, we + // need to do the same here. + Glyph *g = loadGlyphFor(glyph, subPixelPosition, format, matrix, true, true); glyph_metrics_t overall; if (g) { -- cgit v1.2.3