r21811 by jghali - update line natural width while performing justification

scribus-commit scribus-commit at lists.scribus.net
Sat Mar 4 22:22:35 UTC 2017


Author: jghali
Date: Sat Mar  4 22:22:35 2017
New Revision: 21811

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21811
Log:
update line natural width while performing justification

Modified:
    trunk/Scribus/scribus/pageitem_textframe.cpp

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21811&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Sat Mar  4 22:22:35 2017
@@ -902,6 +902,7 @@
 		}
 
 		double glyphScale = 1 + glyphExtension;
+		double naturalWidth = 0;
 
 	/*
 		qDebug() << QString("justify: line = %7 natural = %1 + %2 = %3 (%4); spaces + %5%%; min=%8; glyphs + %6%%; min=%9")
@@ -912,7 +913,10 @@
 
 		int startItem = 0;
 		if (glyphs[startItem].hasFlag(ScLayout_DropCap))
+		{
 			startItem++;
+			naturalWidth += glyphs[startItem].width();
+		}
 		// distribute whitespace on spaces and glyphs
 		for (int i = startItem; i < glyphsCount; ++i)
 		{
@@ -936,25 +940,15 @@
 			{
 				glyphCluster.extraWidth += trackingAmount;
 			}
-
-		}
+			naturalWidth += glyphCluster.width();
+		}
+		lineData.naturalWidth = naturalWidth;
 
 		if ((style.alignment() == ParagraphStyle::Extended) &&
-			(style.direction() == ParagraphStyle::RTL) &&
-			(!trackingInsertion && (spaceExtension == 0)))
-		{
-			double naturalWidth = lineData.naturalWidth;
-			if (glyphScale != 1.0)
-			{
-				naturalWidth = 0;
-				for (int i = 0; i < glyphsCount; ++i)
-				{
-					const GlyphCluster& glyphCluster = glyphs.at(i);
-					naturalWidth += glyphCluster.width();
-				}
-			}
-			double offset = lineData.width - naturalWidth;
-			if (offset > 0)
+			(style.direction() == ParagraphStyle::RTL))
+		{
+			double offset = lineData.width - lineData.naturalWidth;
+			if (offset > 1e-6)
 				indentLine(style, offset);
 		}
 	}




More information about the scribus-commit mailing list