From 8f57fae59ca501b968c3e7d27100e4753b1e0602 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Mon, 5 Dec 2011 11:29:04 +1000 Subject: [PATCH] Prevent consecutive images from climbing up a text node. Vertically position all nodes at the baseline minus their ascent. Previously the bounding rect of a glyph run was postioned on the base line and images at the baseline minus the ascent. This meant that calculated position of an image was correct if it followed text but if it followed another image it would be positioned above it. Change-Id: I03f5e0b48f132f010d16c49620fa9463873f9492 Reviewed-by: Yann Bodson --- src/quick/items/qquicktextnode.cpp | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp index bfb3591..d3b396d 100644 --- a/src/quick/items/qquicktextnode.cpp +++ b/src/quick/items/qquicktextnode.cpp @@ -252,6 +252,9 @@ namespace { decorations |= (backgroundColor.isValid() ? QQuickTextNode::Background : QQuickTextNode::NoDecoration); qreal ascent = glyphRun.rawFont().ascent(); + // ### QTBUG-22919 The bounding rect returned by QGlyphRun appears to start on the + // baseline, move it by the ascent so all bounding rects are at baseline - ascent. + searchRect.translate(0, -ascent); insert(binaryTree, BinaryTreeNode(glyphRun, selectionState, searchRect, decorations, textColor, backgroundColor, position, ascent)); } @@ -631,10 +634,10 @@ namespace { const BinaryTreeNode *lastNode = m_currentLineTree.data() + m_currentLineTree.size() - 1; if (lastNode->glyphRun.isRightToLeft()) { QPointF lastPos = lastNode->boundingRect.topLeft(); - searchRect.moveTopRight(lastPos - QPointF(0, ascent)); + searchRect.moveTopRight(lastPos - QPointF(0, ascent - lastNode->ascent)); } else { QPointF lastPos = lastNode->boundingRect.topRight(); - searchRect.moveTopLeft(lastPos - QPointF(0, ascent)); + searchRect.moveTopLeft(lastPos - QPointF(0, ascent - lastNode->ascent)); } } } -- 1.7.2.5