diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2014-01-29 19:52:41 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-30 12:43:33 +0100 |
commit | d8225fab8fb8b21fb5d35968d9edb5340b76bcc2 (patch) | |
tree | 6d741ff57ac23cd0bf9d2090fecec19f89bf87a9 /src/gui/text/qfontengine.cpp | |
parent | e707607ab0c9935ea744e43bc2b2948b5502360b (diff) |
[QFontEngineBox] Fix incorrect advances for SMP code points
In UTF-16, SMP code point is encoded with a pair of surrogates,
thus making SMP code point twice wider than BMP code point.
Change-Id: Ifb0e78cff50cca7231d07097a730188bd98c54cb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/gui/text/qfontengine.cpp')
-rw-r--r-- | src/gui/text/qfontengine.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 7dfd9423e9..a3fce197ce 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1299,17 +1299,24 @@ QFontEngineBox::~QFontEngineBox() { } -bool QFontEngineBox::stringToCMap(const QChar *, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const +bool QFontEngineBox::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const { if (*nglyphs < len) { *nglyphs = len; return false; } - memset(glyphs->glyphs, 0, len * sizeof(glyph_t)); + int ucs4Length = 0; + for (int i = 0; i < len; ++i) { + if (str[i].isHighSurrogate() && i + 1 < len && str[i + 1].isLowSurrogate()) + ++ucs4Length; + ++ucs4Length; + } + + memset(glyphs->glyphs, 0, ucs4Length * sizeof(glyph_t)); - *nglyphs = len; - glyphs->numGlyphs = len; + *nglyphs = ucs4Length; + glyphs->numGlyphs = ucs4Length; if (!(flags & GlyphIndicesOnly)) recalcAdvances(glyphs, flags); |