diff options
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qtextboundaryfinder.cpp | 9 | ||||
-rw-r--r-- | src/corelib/tools/qunicodetools.cpp | 5 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/corelib/tools/qtextboundaryfinder.cpp b/src/corelib/tools/qtextboundaryfinder.cpp index 1e12d6e4a3..042f92f1e7 100644 --- a/src/corelib/tools/qtextboundaryfinder.cpp +++ b/src/corelib/tools/qtextboundaryfinder.cpp @@ -374,8 +374,7 @@ int QTextBoundaryFinder::toNextBoundary() ++pos; break; case Line: - Q_ASSERT(pos); - while (pos < length && d->attributes[pos-1].lineBreakType == HB_NoBreak) + while (pos < length && d->attributes[pos].lineBreakType == HB_NoBreak) ++pos; break; } @@ -417,7 +416,7 @@ int QTextBoundaryFinder::toPreviousBoundary() --pos; break; case Line: - while (pos > 0 && d->attributes[pos-1].lineBreakType == HB_NoBreak) + while (pos > 0 && d->attributes[pos].lineBreakType == HB_NoBreak) --pos; break; } @@ -442,7 +441,7 @@ bool QTextBoundaryFinder::isAtBoundary() const case Word: return d->attributes[pos].wordBoundary; case Line: - return (pos > 0) ? d->attributes[pos-1].lineBreakType != HB_NoBreak : true; + return pos == 0 || d->attributes[pos].lineBreakType != HB_NoBreak; case Sentence: return d->attributes[pos].sentenceBoundary; } @@ -458,7 +457,7 @@ QTextBoundaryFinder::BoundaryReasons QTextBoundaryFinder::boundaryReasons() cons return NotAtBoundary; if (! isAtBoundary()) return NotAtBoundary; - if (t == Line && pos < length && d->attributes[pos-1].lineBreakType == HB_SoftHyphen) + if (t == Line && pos < length && d->attributes[pos].lineBreakType == HB_SoftHyphen) return SoftHyphen; if (pos == 0) { if (d->attributes[pos].whiteSpace) diff --git a/src/corelib/tools/qunicodetools.cpp b/src/corelib/tools/qunicodetools.cpp index a311213ede..5845765e46 100644 --- a/src/corelib/tools/qunicodetools.cpp +++ b/src/corelib/tools/qunicodetools.cpp @@ -239,7 +239,10 @@ static void calcGraphemeAndLineBreaks(const ushort *string, quint32 len, HB_Char grapheme = ngrapheme; attributes[i-1].lineBreakType = lineBreakType; } - attributes[len-1].lineBreakType = HB_ForcedBreak; + + for (quint32 i = len - 1; i > 0; --i) + attributes[i].lineBreakType = attributes[i - 1].lineBreakType; + attributes[0].lineBreakType = HB_NoBreak; // LB2 } |