summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextlayout.cpp
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-07-27 10:42:40 +0200
committerJiang Jiang <jiang.jiang@nokia.com>2011-07-27 11:14:03 +0200
commitcc500b182e26d53ca16136f24a06a111f4374425 (patch)
treeed376cc75c77a8cf3131e062449a45889b6cddd4 /src/gui/text/qtextlayout.cpp
parent91be1263b42a0a91daf3f905661e356e31482fd3 (diff)
Save previous font engine for right bearing adjustment
In last fix I forgot that fd818312 was for saving and restoring the right bearing (of last visible glyph) when a LineSeparator was hit (which can have a different font engine but usually not visble), thus we can't reset previousGlyph in that case. To make sure we still get correct right bearing from the font engine used to shape previousGlyph, we need to save that font engine as well. It does make the code more complicated than simply saving the right bearing when a QScriptItem boundary is hit, so hopefully it's an optimization worth to be made (following e1915815). Task-number: QTBUG-20423 Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r--src/gui/text/qtextlayout.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 01adecf0b1..d180f0edc5 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1715,6 +1715,7 @@ namespace {
QFixed minimumRightBearing;
QFontEngine *fontEngine;
+ QFontEngine *previousFontEngine;
const unsigned short *logClusters;
bool manualWrap;
@@ -1735,12 +1736,19 @@ namespace {
return glyphs.glyphs[logClusters[currentPosition - 1]];
}
- inline void saveCurrentGlyph()
+ inline void resetPreviousGlyph()
{
previousGlyph = 0;
+ previousFontEngine = 0;
+ }
+
+ inline void saveCurrentGlyph()
+ {
+ resetPreviousGlyph();
if (currentPosition > 0 &&
logClusters[currentPosition - 1] < glyphs.numGlyphs) {
previousGlyph = currentGlyph(); // needed to calculate right bearing later
+ previousFontEngine = fontEngine;
}
}
@@ -1760,8 +1768,11 @@ namespace {
inline void adjustPreviousRightBearing()
{
- if (previousGlyph > 0)
- adjustRightBearing(previousGlyph);
+ if (previousGlyph > 0 && previousFontEngine) {
+ qreal rb;
+ previousFontEngine->getGlyphBearings(previousGlyph, 0, &rb);
+ rightBearing = qMin(QFixed(), QFixed::fromReal(rb));
+ }
}
inline void resetRightBearing()
@@ -1851,7 +1862,7 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.currentPosition = line.from;
int end = 0;
lbh.logClusters = eng->layoutData->logClustersPtr;
- lbh.previousGlyph = 0;
+ lbh.resetPreviousGlyph();
while (newItem < eng->layoutData->items.size()) {
lbh.resetRightBearing();
@@ -1869,7 +1880,6 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.currentPosition = qMax(line.from, current.position);
end = current.position + eng->length(item);
lbh.glyphs = eng->shapedGlyphs(&current);
- lbh.previousGlyph = 0;
QFontEngine *fontEngine = eng->fontEngine(current);
if (lbh.fontEngine != fontEngine) {
lbh.fontEngine = fontEngine;