QTextBlock: Handle surrogates in textDirection()

just like QString does.

Change-Id: I002827d9ec93fb19ef2c0198b5fcd4dae15c5c34
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
Konstantin Ritt 2012-10-15 01:37:03 +03:00 committed by The Qt Project
parent 34823524ae
commit 46ed9dbaa0

View File

@ -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: