From 612ac2b8c8e0d5c67b17ad3a9a564f5a049846a6 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 10 Oct 2011 17:43:59 +0200 Subject: [PATCH] Don't crash when no usable font is available We will fallback to box engine when no usable font is available, and QRawFont (which scenegraph depends on) won't allocate glyph index array on certain occasions. In those cases, QFontEngineBox needs to support GlyphIndicesOnly flag. Change-Id: I408ddd1b2f1a5f7ac2b6681cb7bf531bbbfc68e6 Reviewed-on: http://codereview.qt-project.org/6360 Sanity-Review: Qt Sanity Bot Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index fabd8c3634..1960b1e9b2 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1197,7 +1197,7 @@ QFontEngineBox::~QFontEngineBox() { } -bool QFontEngineBox::stringToCMap(const QChar *, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags) const +bool QFontEngineBox::stringToCMap(const QChar *, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const { if (*nglyphs < len) { *nglyphs = len; @@ -1206,8 +1206,10 @@ bool QFontEngineBox::stringToCMap(const QChar *, int len, QGlyphLayout *glyphs, for (int i = 0; i < len; i++) { glyphs->glyphs[i] = 0; - glyphs->advances_x[i] = _size; - glyphs->advances_y[i] = 0; + if (!(flags & QTextEngine::GlyphIndicesOnly)) { + glyphs->advances_x[i] = _size; + glyphs->advances_y[i] = 0; + } } *nglyphs = len;