From 535086e9e59bb21dca9ee33ba2c6c55e1aded6a7 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 8 Feb 2014 23:49:32 +0200 Subject: [PATCH] QFontEngineBox: Fix assertion for code points beyond BMP ...due to a typo introduced in d8225fab8fb8b21fb5d and stricter checks introduced in 4e319ca4c47a99295c1. This uses recently added QStringIterator to decrease the code duplication. Change-Id: Ib1c2519db1c4d65f3ac14e6f9ae3fa272860b1dd Reviewed-by: Simon Hausmann --- src/gui/text/qfontengine.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index d4e2090c8f..500ea28e2e 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -48,6 +48,7 @@ #include "qvarlengtharray.h" #include #include +#include #ifdef QT_ENABLE_HARFBUZZ_NG # include "qharfbuzzng_p.h" @@ -1364,14 +1365,12 @@ bool QFontEngineBox::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph } int ucs4Length = 0; - for (int i = 0; i < len; ++i) { - if (str[i].isHighSurrogate() && i + 1 < len && str[i + 1].isLowSurrogate()) - ++ucs4Length; - ++ucs4Length; + QStringIterator it(str, str + len); + while (it.hasNext()) { + it.advance(); + glyphs->glyphs[ucs4Length++] = 0; } - memset(glyphs->glyphs, 0, ucs4Length * sizeof(glyph_t)); - *nglyphs = ucs4Length; glyphs->numGlyphs = ucs4Length;