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 104e6d0f54 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 <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Eskil Abrahamsen Blomfeldt 2021-11-30 13:02:18 +01:00
parent 0de5fcafe2
commit bda75c81f5
1 changed files with 4 additions and 1 deletions

View File

@ -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) {