Index: scribus/pageitem_textframe.cpp
===================================================================
--- scribus/pageitem_textframe.cpp	(revision 13356)
+++ scribus/pageitem_textframe.cpp	(working copy)
@@ -493,19 +493,32 @@
 	/// find x position where this line must end
 	double endOfLine(const QRegion& shape, const QMatrix& pf2, double ascent, double descent, double morespace = 0)
 	{
-		double EndX = floor(qMax(line.x, qMin(colRight,breakXPos) - 1));
 		QPoint pt1, pt2;
-		//	qDebug() << QString("endx start=%1, hl is '%2'").arg(EndX).arg(hl->ch);
-		do {
-			EndX += 0.125;
-			pt1 = QPoint(qRound(ceil(EndX + insets.Right)), static_cast<int>(yPos+descent));
-			pt2 = QPoint(qRound(ceil(EndX + insets.Right)), static_cast<int>(ceil(yPos-ascent)));
-		} while 
-			(   (EndX + (legacy? lineCorr + insets.Right : 0) < colRight - morespace)
-			  && shape.contains(pf2.map(pt1))
-			  && shape.contains(pf2.map(pt2)) 
-			  );
-		
+		pt1.setY (static_cast<int>(yPos+descent));
+	        pt2.setY (static_cast<int>(ceil(yPos-ascent)));
+		double StartX = floor(qMax(line.x, qMin(colRight,breakXPos) - 1));
+	        double EndX;
+	        // this locates the highest X that falls within the box
+	        // it does so by first finding an interval of size 128
+	        // then it keeps reducing the steps by half, until it gets down
+	        // to 0.125 steps
+	        double Interval = 128.0;
+	        while (Interval > 0.125) {
+	                EndX = StartX;
+
+			do {
+				EndX += Interval;
+	                        int xPos = static_cast<int>(ceil(EndX + insets.Right));
+				pt1.setX (xPos);
+				pt2.setX (xPos);
+			} while 
+				(   (EndX + (legacy? lineCorr + insets.Right : 0) < colRight - morespace)
+				  && shape.contains(pf2.map(pt1))
+				  && shape.contains(pf2.map(pt2)) 
+				  );
+	                StartX = EndX - Interval;
+	                Interval /= 2;
+	        }
 		return EndX;
 	}
 	
