summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2014-03-06 12:02:25 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-10 15:05:01 +0100
commit11eb9d37dc191b6e71c903e4f7f4d2da579e7df5 (patch)
treef2f5695fe82251000b969410bb4860a5ffdecc0d /src/plugins/platforms
parentca280bfe3bc551f814d59d25079e098798fbdad7 (diff)
Use QStringIterator instead of homebrew
Task-number: QTBUG-15664 Change-Id: I1ed3eb04ddd822e57a4d993af656dfe283f3af1a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp34
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp20
2 files changed, 17 insertions, 37 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index e8e2978ee3..6f0a4f9ea5 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -65,6 +65,7 @@
#include <QtCore/qmath.h>
#include <QtCore/QThreadStorage>
#include <QtCore/private/qsystemlibrary_p.h>
+#include <QtCore/private/qstringiterator_p.h>
#include <QtCore/QDebug>
@@ -205,47 +206,37 @@ void QWindowsFontEngine::getCMap()
}
}
-// ### Qt 5.1: replace with QStringIterator
-inline unsigned int getChar(const QChar *str, int &i, const int len)
-{
- uint uc = str[i].unicode();
- if (QChar::isHighSurrogate(uc) && i < len-1) {
- uint low = str[i+1].unicode();
- if (QChar::isLowSurrogate(low)) {
- uc = QChar::surrogateToUcs4(uc, low);
- ++i;
- }
- }
- return uc;
-}
-
int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLayout *glyphs) const
{
- int i = 0;
int glyph_pos = 0;
{
#if defined(Q_OS_WINCE)
{
#else
if (symbol) {
- for (; i < numChars; ++i, ++glyph_pos) {
- unsigned int uc = getChar(str, i, numChars);
+ QStringIterator it(str, str + numChars);
+ while (it.hasNext()) {
+ const uint uc = it.next();
glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc);
if(!glyphs->glyphs[glyph_pos] && uc < 0x100)
glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc + 0xf000);
+ ++glyph_pos;
}
} else if (ttf) {
- for (; i < numChars; ++i, ++glyph_pos) {
- unsigned int uc = getChar(str, i, numChars);
+ QStringIterator it(str, str + numChars);
+ while (it.hasNext()) {
+ const uint uc = it.next();
glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc);
+ ++glyph_pos;
}
} else {
#endif
wchar_t first = tm.tmFirstChar;
wchar_t last = tm.tmLastChar;
- for (; i < numChars; ++i, ++glyph_pos) {
- uint uc = getChar(str, i, numChars);
+ QStringIterator it(str, str + numChars);
+ while (it.hasNext()) {
+ const uint uc = it.next();
if (
#ifdef Q_WS_WINCE
tm.tmFirstChar > 60000 ||
@@ -254,6 +245,7 @@ int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLa
glyphs->glyphs[glyph_pos] = uc;
else
glyphs->glyphs[glyph_pos] = 0;
+ ++glyph_pos;
}
}
}
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
index b6b554d4b0..8f55e20536 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
@@ -53,6 +53,7 @@
#include <QtCore/QSettings>
#include <QtCore/QtEndian>
#include <QtCore/QVarLengthArray>
+#include <private/qstringiterator_p.h>
#include <dwrite.h>
#include <d2d1.h>
@@ -314,20 +315,6 @@ glyph_t QWindowsFontEngineDirectWrite::glyphIndex(uint ucs4) const
return glyphIndex;
}
-// ### Qt 5.1: replace with QStringIterator
-inline unsigned int getChar(const QChar *str, int &i, const int len)
-{
- uint uc = str[i].unicode();
- if (QChar::isHighSurrogate(uc) && i < len-1) {
- uint low = str[i+1].unicode();
- if (QChar::isLowSurrogate(low)) {
- uc = QChar::surrogateToUcs4(uc, low);
- ++i;
- }
- }
- return uc;
-}
-
bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,
int *nglyphs, QFontEngine::ShaperFlags flags) const
{
@@ -339,8 +326,9 @@ bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGly
QVarLengthArray<UINT32> codePoints(len);
int actualLength = 0;
- for (int i = 0; i < len; ++i)
- codePoints[actualLength++] = getChar(str, i, len);
+ QStringIterator it(str, str + len);
+ while (it.hasNext())
+ codePoints[actualLength++] = it.next();
QVarLengthArray<UINT16> glyphIndices(actualLength);
HRESULT hr = m_directWriteFontFace->GetGlyphIndicesW(codePoints.data(), actualLength,