diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2010-06-23 08:10:43 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2010-06-23 08:10:43 (GMT) |
commit | 87ee2e1c4497c67626db09a631577debea362fba (patch) | |
tree | 0b19b5b2ab82066bc3ff59acbdbd4461d7609113 /src | |
parent | 4221d629e2cf37ee8c5ba7cb595b05ab8c82f113 (diff) | |
download | Qt-87ee2e1c4497c67626db09a631577debea362fba.zip Qt-87ee2e1c4497c67626db09a631577debea362fba.tar.gz Qt-87ee2e1c4497c67626db09a631577debea362fba.tar.bz2 |
Improve text performance with QtWebKit in Qt 4.7
Implemented the straight string-to-glyph conversion in the core text
font engine, that bypasses the shaping. This is used by the fast text
code path in QtWebKit.
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/text/qfontengine_mac.mm | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 7ceed61..deaad57 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -348,7 +348,29 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const { - return stringToCMap(str, len, glyphs, nglyphs, flags, 0, 0); + *nglyphs = len; + QVarLengthArray<CGGlyph> cgGlyphs(len); + CTFontGetGlyphsForCharacters(ctfont, (const UniChar*)str, cgGlyphs.data(), len); + + for (int i = 0; i < len; ++i) + glyphs->glyphs[i] = cgGlyphs[i]; + + if (flags & QTextEngine::GlyphIndicesOnly) + return true; + + QVarLengthArray<CGSize> advances(len); + CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, cgGlyphs.data(), advances.data(), len); + + for (int i = 0; i < len; ++i) { + glyphs->advances_x[i] = QFixed::fromReal(advances[i].width); + glyphs->advances_y[i] = QFixed::fromReal(advances[i].height); + if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) { + glyphs->advances_x[i] = glyphs->advances_x[i].round(); + glyphs->advances_y[i] = glyphs->advances_y[i].round(); + } + } + + return true; } void QCoreTextFontEngineMulti::recalcAdvances(int , QGlyphLayout *, QTextEngine::ShaperFlags) const |