summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2012-10-15 01:37:03 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-16 02:47:51 +0200
commit46ed9dbaa0a3627513c1f89c46b5e67d1e1af14b (patch)
tree1c970bc0280bb5a6957352a509069554001ac7e8 /src/gui
parent34823524aed422b13662b9fcb12767b0a7a256de (diff)
QTextBlock: Handle surrogates in textDirection()
just like QString does. Change-Id: I002827d9ec93fb19ef2c0198b5fcd4dae15c5c34 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qtextobject.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index abe1035cd1..349f8869fd 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -1185,8 +1185,15 @@ Qt::LayoutDirection QTextBlock::textDirection() const
const QChar *p = buffer.constData() + frag->stringPosition;
const QChar * const end = p + frag->size_array[0];
while (p < end) {
- switch(QChar::direction(p->unicode()))
- {
+ uint ucs4 = p->unicode();
+ if (QChar::isHighSurrogate(ucs4) && p + 1 < end) {
+ ushort low = p[1].unicode();
+ if (QChar::isLowSurrogate(low)) {
+ ucs4 = QChar::surrogateToUcs4(ucs4, low);
+ ++p;
+ }
+ }
+ switch (QChar::direction(ucs4)) {
case QChar::DirL:
return Qt::LeftToRight;
case QChar::DirR: