summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextlayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r--src/gui/text/qtextlayout.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index dbfe23e..d6535ea 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1664,7 +1664,7 @@ namespace {
{
LineBreakHelper()
: glyphCount(0), maxGlyphs(0), currentPosition(0), fontEngine(0), logClusters(0),
- manualWrap(false)
+ manualWrap(false), whiteSpaceOrObject(true)
{
}
@@ -1687,6 +1687,7 @@ namespace {
const unsigned short *logClusters;
bool manualWrap;
+ bool whiteSpaceOrObject;
bool checkFullOtherwiseExtend(QScriptLine &line);
@@ -1696,8 +1697,10 @@ namespace {
}
inline glyph_t currentGlyph() const
- {
+ {
Q_ASSERT(currentPosition > 0);
+ Q_ASSERT(logClusters[currentPosition - 1] < glyphs.numGlyphs);
+
return glyphs.glyphs[logClusters[currentPosition - 1]];
}
@@ -1832,6 +1835,7 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.tmpData.descent = qMax(lbh.tmpData.descent, current.descent);
if (current.analysis.flags == QScriptAnalysis::Tab && (alignment & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignCenter | Qt::AlignJustify))) {
+ lbh.whiteSpaceOrObject = true;
if (lbh.checkFullOtherwiseExtend(line))
goto found;
@@ -1848,6 +1852,7 @@ void QTextLine::layout_helper(int maxGlyphs)
if (lbh.checkFullOtherwiseExtend(line))
goto found;
} else if (current.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator) {
+ lbh.whiteSpaceOrObject = true;
// if the line consists only of the line separator make sure
// we have a sane height
if (!line.length && !lbh.tmpData.length)
@@ -1861,6 +1866,7 @@ void QTextLine::layout_helper(int maxGlyphs)
line += lbh.tmpData;
goto found;
} else if (current.analysis.flags == QScriptAnalysis::Object) {
+ lbh.whiteSpaceOrObject = true;
lbh.tmpData.length++;
QTextFormat format = eng->formats()->format(eng->formatIndex(&eng->layoutData->items[item]));
@@ -1874,6 +1880,7 @@ void QTextLine::layout_helper(int maxGlyphs)
if (lbh.checkFullOtherwiseExtend(line))
goto found;
} else if (attributes[lbh.currentPosition].whiteSpace) {
+ lbh.whiteSpaceOrObject = true;
while (lbh.currentPosition < end && attributes[lbh.currentPosition].whiteSpace)
addNextCluster(lbh.currentPosition, end, lbh.spaceData, lbh.glyphCount,
current, lbh.logClusters, lbh.glyphs);
@@ -1883,6 +1890,7 @@ void QTextLine::layout_helper(int maxGlyphs)
goto found;
}
} else {
+ lbh.whiteSpaceOrObject = false;
bool sb_or_ws = false;
do {
addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount,
@@ -1944,7 +1952,7 @@ void QTextLine::layout_helper(int maxGlyphs)
LB_DEBUG("reached end of line");
lbh.checkFullOtherwiseExtend(line);
found:
- if (lbh.rightBearing > 0) // If right bearing has not yet been adjusted
+ if (lbh.rightBearing > 0 && !lbh.whiteSpaceOrObject) // If right bearing has not yet been adjusted
lbh.adjustRightBearing();
line.textAdvance = line.textWidth;
line.textWidth -= qMin(QFixed(), lbh.rightBearing);