CoreText: prevent colored glyphs (like emoji) to be clipped

To prevent colored glyphs (like emoji) from being cut off at the edges,
we can simply apply the solution from bbba71748438dc05d344bb9727f10b7f55a5d229
to colored glyphs as well (i.e. to glyphs with QFontEngine::Format_ARGB format).

Fixes: QTBUG-133297
Pick-to: 6.8
Change-Id: I5578e2d12f956d0635b662b3ecf714aa63474945
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 7cc0ea0b5a1dc1d9e1a9a8cc8639958e42adba3a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Vladimir Belyavsky 2025-01-28 22:04:40 +03:00 committed by Qt Cherry-pick Bot
parent d7ff69741b
commit d35a1eb1ac

View File

@ -591,8 +591,9 @@ glyph_metrics_t QCoreTextFontEngine::alphaMapBoundingBox(glyph_t glyph, const QF
if (br.height < 0)
br.height = -br.height;
if (format == QFontEngine::Format_A8 || format == QFontEngine::Format_A32) {
// Drawing a glyph at x-position 0 with anti-aliasing enabled
if (format == QFontEngine::Format_A8 || format == QFontEngine::Format_A32 || format == QFontEngine::Format_ARGB) {
// Drawing a vector based glyph with anti-aliasing enabled, or a
// bitmap based glyph with pre-baked anti-aliasing, at x = 0,
// will potentially fill the pixel to the left of 0, as the
// coordinates are not aligned to the center of pixels. To
// prevent clipping of this pixel we need to shift the glyph