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_win.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 <[email protected]>
Reviewed-by: Lars Knoll <[email protected]>
Diffstat (limited to 'src/gui/text/qfontengine_win.cpp')
-rw-r--r-- | src/gui/text/qfontengine_win.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index bd9a437999..6ad5eb4915 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -215,9 +215,8 @@ void QFontEngineWin::getCMap() bool symb = false; if (ttf) { cmapTable = getSfntTable(qbswap<quint32>(MAKE_TAG('c', 'm', 'a', 'p'))); - int size = 0; cmap = QFontEngine::getCMap(reinterpret_cast<const uchar *>(cmapTable.constData()), - cmapTable.size(), &symb, &size); + cmapTable.size(), &symb, &cmapSize); } if (!cmap) { ttf = false; @@ -263,14 +262,14 @@ int QFontEngineWin::getGlyphIndexes(const QChar *str, int numChars, QGlyphLayout if (symbol) { for (; i < numChars; ++i, ++glyph_pos) { unsigned int uc = getChar(str, i, numChars); - glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc); + glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc); if (!glyphs->glyphs[glyph_pos] && uc < 0x100) - glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc + 0xf000); + glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc + 0xf000); } } else if (ttf) { for (; i < numChars; ++i, ++glyph_pos) { unsigned int uc = getChar(str, i, numChars); - glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, QChar::mirroredChar(uc)); + glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, QChar::mirroredChar(uc)); } } else { #endif @@ -296,14 +295,14 @@ int QFontEngineWin::getGlyphIndexes(const QChar *str, int numChars, QGlyphLayout if (symbol) { for (; i < numChars; ++i, ++glyph_pos) { unsigned int uc = getChar(str, i, numChars); - glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc); + glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc); if(!glyphs->glyphs[glyph_pos] && uc < 0x100) - glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc + 0xf000); + glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc + 0xf000); } } else if (ttf) { for (; i < numChars; ++i, ++glyph_pos) { unsigned int uc = getChar(str, i, numChars); - glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc); + glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc); } } else { #endif @@ -335,6 +334,7 @@ QFontEngineWin::QFontEngineWin(const QString &name, HFONT _hfont, bool stockFont _name = name; cmap = 0; + cmapSize = 0; hfont = _hfont; logfont = lf; HDC hdc = shared_dc(); @@ -811,9 +811,9 @@ bool QFontEngineWin::canRender(const QChar *string, int len) if (symbol) { for (int i = 0; i < len; ++i) { unsigned int uc = getChar(string, i, len); - if (getTrueTypeGlyphIndex(cmap, uc) == 0) { + if (getTrueTypeGlyphIndex(cmap, cmapSize, uc) == 0) { if (uc < 0x100) { - if (getTrueTypeGlyphIndex(cmap, uc + 0xf000) == 0) + if (getTrueTypeGlyphIndex(cmap, cmapSize, uc + 0xf000) == 0) return false; } else { return false; @@ -823,7 +823,7 @@ bool QFontEngineWin::canRender(const QChar *string, int len) } else if (ttf) { for (int i = 0; i < len; ++i) { unsigned int uc = getChar(string, i, len); - if (getTrueTypeGlyphIndex(cmap, uc) == 0) + if (getTrueTypeGlyphIndex(cmap, cmapSize, uc) == 0) return false; } } else { |