diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-10-19 10:01:04 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-10-21 10:56:40 +0200 |
commit | d587f0139d8584b667705e1b0d3bb892346cf4f9 (patch) | |
tree | ff7d52ac4e7ba7d49b8b2d3761220bf148a509d7 /src | |
parent | 322ada57e91e2e38d26efb88f7250c3c2bfb49cc (diff) |
Use valid glyph index for box font engine
Glyph index 0 is reserved for "glyph not found", which can
confuse Harfbuzz. For QFontEngineBox we always return a valid
glyph since it is the fallback font when no other fonts are
available.
Symptom of issue was that we could get to Q_UNREACHABLE for
certain strings when Harfbuzz returned a glyph count of 0.
[ChangeLog][QtGui] Fixed a potential crash when rendering text
with an empty font database.
Fixes: QTBUG-85016
Change-Id: Iaf1d003cdff57320bf4327aa8e63dffd9d1da82c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 05078459de5dae65b9bb7cf2a1bc216528291648)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/text/qfontengine.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index d745a70a9a..f1fd755e91 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1600,7 +1600,7 @@ QFontEngineBox::~QFontEngineBox() glyph_t QFontEngineBox::glyphIndex(uint ucs4) const { Q_UNUSED(ucs4) - return 0; + return 1; } bool QFontEngineBox::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const @@ -1615,7 +1615,7 @@ bool QFontEngineBox::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph QStringIterator it(str, str + len); while (it.hasNext()) { it.advance(); - glyphs->glyphs[ucs4Length++] = 0; + glyphs->glyphs[ucs4Length++] = 1; } *nglyphs = ucs4Length; |