src/gui/text/qtextlayout.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
child 33 3e2da88830cd
--- a/src/gui/text/qtextlayout.cpp	Mon Jun 21 22:38:13 2010 +0100
+++ b/src/gui/text/qtextlayout.cpp	Thu Jul 22 16:41:55 2010 +0100
@@ -305,7 +305,7 @@
     Once the layout is done, these lines can be drawn on a paint
     device.
 
-    Here's some pseudo code that presents the layout phase:
+    Here's some code snippet that presents the layout phase:
     \snippet doc/src/snippets/code/src_gui_text_qtextlayout.cpp 0
 
     The text can be drawn by calling the layout's draw() function:
@@ -1570,6 +1570,20 @@
     return eng->lines[i].textWidth.toReal();
 }
 
+/*! \since 4.7
+  Returns the horizontal advance of the text. The advance of the text
+  is the distance from its position to the next position at which
+  text would naturally be drawn.
+
+  By adding the advance to the position of the text line and using this
+  as the position of a second text line, you will be able to position
+  the two lines side-by-side without gaps in-between.
+*/
+qreal QTextLine::horizontalAdvance() const
+{
+    return eng->lines[i].textAdvance.toReal();
+}
+
 /*!
     Lays out the line with the given \a width. The line is filled from
     its starting position with as many characters as will fit into
@@ -1928,6 +1942,7 @@
 found:       
     if (lbh.rightBearing > 0) // If right bearing has not yet been adjusted
         lbh.adjustRightBearing();
+    line.textAdvance = line.textWidth;
     line.textWidth -= qMin(QFixed(), lbh.rightBearing);
 
     if (line.length == 0) {