From 3f3f46d61500011eb2ef5d1bb57324a24b05a6ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 13 Jun 2023 13:27:49 +0200 Subject: [PATCH] FontEngine: Skip 0-width glyphs when finding first left bearing Since they don't contribute to the width of a string then we may accidentally end up ignoring the potential left-bearing that the first non-zero-width glyph has. Task-number: QTBUG-113679 Change-Id: I8e89a428acf5d0a3da0255c50778ccc773ff20e1 Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 8469b369287609ed7b179ff846d64c8b408498ca) Reviewed-by: Qt Cherry-pick Bot --- src/gui/text/qfontengine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 5035b61fe95..a402a6a006a 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1471,10 +1471,10 @@ bool QFontEngine::hasUnreliableGlyphOutline() const QFixed QFontEngine::firstLeftBearing(const QGlyphLayout &glyphs) { - if (glyphs.numGlyphs >= 1) { - glyph_t glyph = glyphs.glyphs[0]; + for (int i = 0; i < glyphs.numGlyphs; ++i) { + glyph_t glyph = glyphs.glyphs[i]; glyph_metrics_t gi = boundingBox(glyph); - if (gi.isValid()) + if (gi.isValid() && gi.width > 0) return gi.leftBearing(); } return 0;