diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com> | 2015-07-10 13:22:32 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-10-23 08:59:45 +0000 |
commit | 0a2f2382541424726168804be2c90b91381608c6 (patch) | |
tree | 1e35fbd18f77ac56ff4a38ed419c434504bb187c /src/gui/text/qfontengine_s60.cpp | |
parent | b05d05fd9ce2aeedfaf805a7ed9007a93c902bc9 (diff) |
Specifically when reading files with broken cmap tables, we could
get some undeterministic results. We handle this more gracefully
by verifying that the offsets are sane and bailing out early if not.
This replaces the current pattern throughout the font engine for
consistency.
This is a back-port of 4a1e5dbade4bab55f39bd368480dcca9a11e4b38
from Qt 5.
Change-Id: If4172b9ef0808801c8e27ffaad962535afe572ed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/gui/text/qfontengine_s60.cpp')
-rw-r--r-- | src/gui/text/qfontengine_s60.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 1da501a92b..b2bb5610b2 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -77,6 +77,7 @@ QSymbianTypeFaceExtras::QSymbianTypeFaceExtras(CFont* cFont, COpenFont *openFont : m_cFont(cFont) , m_symbolCMap(false) , m_openFont(openFont) + , m_cmapSize(0) { if (!symbianFontTableApiAvailable()) { TAny *trueTypeExtension = NULL; @@ -161,10 +162,9 @@ const uchar *QSymbianTypeFaceExtras::cmap() const { if (m_cmapTable.isNull()) { const QByteArray cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p')); - int size = 0; const uchar *cmap = QFontEngine::getCMap(reinterpret_cast<const uchar *> - (cmapTable.constData()), cmapTable.size(), &m_symbolCMap, &size); - m_cmapTable = QByteArray(reinterpret_cast<const char *>(cmap), size); + (cmapTable.constData()), cmapTable.size(), &m_symbolCMap, &m_cmapSize); + m_cmapTable = QByteArray(reinterpret_cast<const char *>(cmap), m_cmapSize); } return reinterpret_cast<const uchar *>(m_cmapTable.constData()); } @@ -324,6 +324,7 @@ bool QFontEngineS60::stringToCMap(const QChar *characters, int len, QGlyphLayout for (int i = 0; i < len; ++i) { const unsigned int uc = getChar(characters, i, len); *g++ = QFontEngine::getTrueTypeGlyphIndex(cmap, + m_cmapSize, (isRtl && !m_extras->isSymbolCMap()) ? QChar::mirroredChar(uc) : uc); } @@ -463,7 +464,7 @@ bool QFontEngineS60::canRender(const QChar *string, int len) const unsigned char *cmap = m_extras->cmap(); for (int i = 0; i < len; ++i) { const unsigned int uc = getChar(string, i, len); - if (QFontEngine::getTrueTypeGlyphIndex(cmap, uc) == 0) + if (QFontEngine::getTrueTypeGlyphIndex(cmap, m_cmapSize, uc) == 0) return false; } return true; |