QGlyphRun: always use stored bounding rect even if it's empty

QGlyphRun's bounding rectangle may have zero width, e.g. when it
contains only non-printable characters. Some code, e.g.
QTextLine::glyphRuns(), may pre-calculate bounding rectangle for
QGlyphRun and store it inside via QGlyphRun::setBoundingRect().

Previously, we would ignore empty rects as an indication that no
bounding rect had been set on the QGlyphRun. This should be
checking for valid rects instead, to allow for runs containing
non-printable characters exclusively.

Fixes: QTBUG-96463
Pick-to: 6.2
Change-Id: Ia934749cfda37e60ebf98fb76536434054baa4d1
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Vladimir Belyavsky 2021-12-12 14:54:05 +03:00 committed by Eskil Abrahamsen Blomfeldt
parent 3f6041fb82
commit 20d869f4c5

View File

@ -434,7 +434,7 @@ void QGlyphRun::setFlags(GlyphRunFlags flags)
/*!
Sets the bounding rect of the glyphs in this QGlyphRun to be \a boundingRect. This rectangle
will be returned by boundingRect() unless it is empty, in which case the bounding rectangle of the
will be returned by boundingRect() unless it is null, in which case the bounding rectangle of the
glyphs in the glyph run will be returned instead.
\note Unless you are implementing text shaping, you should not have to use this function.
@ -468,7 +468,7 @@ void QGlyphRun::setBoundingRect(const QRectF &boundingRect)
*/
QRectF QGlyphRun::boundingRect() const
{
if (!d->boundingRect.isEmpty() || !d->rawFont.isValid())
if (!d->boundingRect.isNull() || !d->rawFont.isValid())
return d->boundingRect;
qreal minX, minY, maxX, maxY;