From 64847a3930a1d29dfec47dc6fd084f42deeced20 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 28 Nov 2022 13:13:41 +0100 Subject: [PATCH] Don't return empty glyph runs from QTextLine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last (or only) QGlyphRun would be ignored if it did not contain any glyphs, but we did not have the same conditions for substrings represented by different font engines. This was an oversight and we should be consistent. Pick-to: 6.4 Task-number: QTBUG-108799 Change-Id: Idfa187f6198247d5cc94804a4e55d5de3ccd739e Reviewed-by: Tor Arne Vestbø --- src/gui/text/qtextlayout.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index d168a77d57f..6eaefc945cc 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2534,19 +2534,23 @@ QList QTextLine::glyphRuns(int from, if (start == 0 && startsInsideLigature) subFlags |= QGlyphRun::SplitLigature; - glyphRuns.append(glyphRunWithInfo(multiFontEngine->engine(which), - eng->text, - subLayout, - pos, - subFlags, - retrievalFlags, - x, - width, - glyphsStart + start, - glyphsStart + end, - logClusters + relativeFrom, - relativeFrom + si.position, - relativeTo - relativeFrom + 1)); + { + QGlyphRun glyphRun = glyphRunWithInfo(multiFontEngine->engine(which), + eng->text, + subLayout, + pos, + subFlags, + retrievalFlags, + x, + width, + glyphsStart + start, + glyphsStart + end, + logClusters + relativeFrom, + relativeFrom + si.position, + relativeTo - relativeFrom + 1); + if (!glyphRun.isEmpty()) + glyphRuns.append(glyphRun); + } for (int i = 0; i < subLayout.numGlyphs; ++i) { QFixed justification = QFixed::fromFixed(subLayout.justifications[i].space_18d6); pos.rx() += (subLayout.advances[i] + justification).toReal();