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 <allan.jensen@qt.io>
(cherry picked from commit 8469b369287609ed7b179ff846d64c8b408498ca)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Mårten Nordheim 2023-06-13 13:27:49 +02:00 committed by Qt Cherry-pick Bot
parent e799b3de67
commit 3f3f46d615

View File

@ -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;