diff options
author | Eskil Abrahamsen Blomfeldt <[email protected]> | 2015-07-10 13:22:32 +0200 |
---|---|---|
committer | Oswald Buddenhagen <[email protected]> | 2015-10-23 08:59:45 +0000 |
commit | 0a2f2382541424726168804be2c90b91381608c6 (patch) | |
tree | 1e35fbd18f77ac56ff4a38ed419c434504bb187c /src/gui/text/qfontengine_mac.mm | |
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 <[email protected]>
Reviewed-by: Lars Knoll <[email protected]>
Diffstat (limited to 'src/gui/text/qfontengine_mac.mm')
-rw-r--r-- | src/gui/text/qfontengine_mac.mm | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index ba01f4c6fa..460aa5fd65 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -625,7 +625,7 @@ bool QFontEngineMacMulti::canRender(const QChar *string, int len) } QFontEngineMac::QFontEngineMac(ATSUStyle baseStyle, ATSUFontID fontID, const QFontDef &def, QFontEngineMacMulti *multiEngine) - : fontID(fontID), multiEngine(multiEngine), cmap(0), symbolCMap(false) + : fontID(fontID), multiEngine(multiEngine), cmap(0), symbolCMap(false), cmapSize(0) { fontDef = def; ATSUCreateAndCopyStyle(baseStyle, &style); @@ -747,22 +747,21 @@ bool QFontEngineMac::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph { if (!cmap) { cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p')); - int size = 0; - cmap = getCMap(reinterpret_cast<const uchar *>(cmapTable.constData()), cmapTable.size(), &symbolCMap, &size); + cmap = getCMap(reinterpret_cast<const uchar *>(cmapTable.constData()), cmapTable.size(), &symbolCMap, &cmapSize); if (!cmap) return false; } if (symbolCMap) { for (int i = 0; i < len; ++i) { unsigned int uc = getChar(str, i, len); - glyphs->glyphs[i] = getTrueTypeGlyphIndex(cmap, uc); + glyphs->glyphs[i] = getTrueTypeGlyphIndex(cmap, cmapSize, uc); if(!glyphs->glyphs[i] && uc < 0x100) - glyphs->glyphs[i] = getTrueTypeGlyphIndex(cmap, uc + 0xf000); + glyphs->glyphs[i] = getTrueTypeGlyphIndex(cmap, cmapSize, uc + 0xf000); } } else { for (int i = 0; i < len; ++i) { unsigned int uc = getChar(str, i, len); - glyphs->glyphs[i] = getTrueTypeGlyphIndex(cmap, uc); + glyphs->glyphs[i] = getTrueTypeGlyphIndex(cmap, cmapSize, uc); } } |