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
Pick-to: 6.6
Change-Id: I8e89a428acf5d0a3da0255c50778ccc773ff20e1
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
bb10
Mårten Nordheim 2023-06-13 13:27:49 +02:00
parent 2271ee6b4b
commit 8469b36928
1 changed files with 3 additions and 3 deletions

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;