From 214101b1b361166870357e3576f3a3792a7d0a7e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 8 Nov 2024 09:40:40 +0100 Subject: [PATCH] Remove assert in QImageTextureGlyphCache::fillTexture() The assert assumes that we are calculating the transformed bounds of a glyph with exactly the same parameters as the image of the glyph is later transformed. However, when calculating the new bounding box of the glyph in alphaMapBoundingBox, we do: t.mapRect(QRectF(gx, gy, gw, gh)) And then round the width and height up. When we transform the image of the glyph, we do: t.mapRect(QRectF(0, 0, gw, gh)).toAlignedRect() Note the origin is at origo and we align the rect. This can lead to the actual transformed image sometimes being larger than what is returned from alphaMapBoundingBox(). We could change alphaMapBoundingBox() to match the behavior of the image transform, but it has a risk of missing some corner cases, especially given that the same code paths are used for scalable bitmap fonts. In the end, just removing the assert is safe, since there is a qMin() protecting against buffer overruns later, and there does not seem to be any visual difference from actually calculating the correct bounds. [ChangeLog][Freetype] Fixed possible assert when transforming bitmap fonts. Pick-to: 6.5 Fixes: QTBUG-130930 Change-Id: I0406e6f45e0d436a5248dd986703bb3a9288b9f4 Reviewed-by: Paul Olav Tvete (cherry picked from commit fd75a66f3f65f6c8e8bfb933260676b5c18f2df1) Reviewed-by: Qt Cherry-pick Bot --- src/gui/painting/qtextureglyphcache.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 70d70e342a8..d27539b2419 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -309,8 +309,6 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, return; } #endif - Q_ASSERT(mask.width() <= c.w && mask.height() <= c.h); - if (m_format == QFontEngine::Format_A32 || m_format == QFontEngine::Format_ARGB) { QImage ref(m_image.bits() + (c.x * 4 + c.y * m_image.bytesPerLine()),