Calculate correct bounding rect for glyph runs in QTextLayout
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Mon, 2 Apr 2012 13:07:55 +0000 (15:07 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 2 Apr 2012 14:56:48 +0000 (16:56 +0200)
The positions returned by getGlyphPositions() in QFontEngine are
for the base line of the glyphs. We offset this by -ascent to get
the top of the actual bounding rect.

Task-number: QTBUG-22919
Change-Id: Id82c66ecfbdf58064f5ad26f4193fa55ac26bc7c
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
src/gui/text/qtextlayout.cpp

index d7f8130..dddb802 100644 (file)
@@ -2170,7 +2170,8 @@ static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine, const QGlyphLayout &g
     glyphRun.setFlags(flags);
     glyphRun.setRawFont(font);
 
-    glyphRun.setBoundingRect(QRectF(selectionX.toReal(), minY, selectionWidth.toReal(), height));
+    glyphRun.setBoundingRect(QRectF(selectionX.toReal(), minY - font.ascent(),
+                                    selectionWidth.toReal(), height));
 
     return glyphRun;
 }