diff options
author | Raymund Apfelboeck <r.apfelboeck@technisat.de> | 2018-08-02 08:41:08 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2019-03-26 09:03:45 +0000 |
commit | 9beac9838510e94338377fcd1cfc68b371f32a86 (patch) | |
tree | d2b170464eb3ac65d8db9a36cde34a3517c67065 | |
parent | e9662ddd86f027bdbe617f5171cd63cae13b3845 (diff) |
makeqpf: fix crash
Also fix generation of special characters like space
[ChangeLog][makeqpf] Fix assert when rendering font using debug build of Qt
Fixes: QTBUG-46544
Change-Id: Ic17ee44973d3f85b5d2ae4423a059223abd52ea5
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r-- | src/makeqpf/qpf2.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/makeqpf/qpf2.cpp b/src/makeqpf/qpf2.cpp index 508afaa33..c56ec391a 100644 --- a/src/makeqpf/qpf2.cpp +++ b/src/makeqpf/qpf2.cpp @@ -402,10 +402,10 @@ static QByteArray generateTrueTypeCMap(QFontEngine *fe) quint32 previousGlyphIndex = 0xfffffffe; bool inSegment = false; - QGlyphLayoutArray<10> layout; + QGlyphLayoutArray<1> layout; for (uint uc = 0; uc < 0x10000; ++uc) { QChar ch(uc); - int nglyphs = 10; + int nglyphs = 1; bool validGlyph = fe->stringToCMap(&ch, 1, &layout, &nglyphs, /*flags*/ 0) && nglyphs == 1 && layout.glyphs[0]; @@ -503,14 +503,14 @@ void QPF::addGlyphs(QFontEngine *fe, const QList<CharacterRange> &ranges) * (sizeof(QFontEngineQPF2::Glyph) + qRound(fe->maxCharWidth() * (fe->ascent() + fe->descent()).toReal()))); - QGlyphLayoutArray<10> layout; + QGlyphLayoutArray<1> layout; for (CharacterRange range : ranges) { if (debugVerbosity > 2) qDebug() << "rendering range from" << range.start << "to" << range.end; for (uint uc = range.start; uc < range.end; ++uc) { QChar ch(uc); - int nglyphs = 10; + int nglyphs = 1; if (!fe->stringToCMap(&ch, 1, &layout, &nglyphs, /*flags*/ 0)) continue; @@ -524,8 +524,12 @@ void QPF::addGlyphs(QFontEngine *fe, const QList<CharacterRange> &ranges) Q_ASSERT(glyphIndex < glyphCount); - QImage img = fe->alphaMapForGlyph(glyphIndex).convertToFormat(QImage::Format_Indexed8); glyph_metrics_t metrics = fe->boundingBox(glyphIndex); + const bool valid = metrics.width.value() != 0 && metrics.height.value() != 0; + + QImage img = valid + ? fe->alphaMapForGlyph(glyphIndex).convertToFormat(QImage::Format_Indexed8) + : QPixmap(0,0).toImage(); const quint32 oldSize = glyphs.size(); glyphs.resize(glyphs.size() + sizeof(QFontEngineQPF2::Glyph) + img.byteCount()); |