r21240 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Sun Apr 24 16:15:29 UTC 2016


Author: jghali
Date: Sun Apr 24 16:15:29 2016
New Revision: 21240

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21240
Log:
#13977: Text centering does not work correctly after increasing distance between characters

Modified:
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/text/textshaper.cpp
    trunk/Scribus/scribus/text/textshaper.h

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21240&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Sun Apr 24 16:15:29 2016
@@ -1448,9 +1448,15 @@
 		int regionMinY = 0, regionMaxY= 0;
 		double autoLeftIndent = 0.0;
 
-		for (int i = 0; shaper.hasRun(i); ++i)
-		{
+		for (int i = 0; true; ++i)
+		{
+			if (current.isEmpty)
+				shaper.startLine(i);
+
+			if (!shaper.hasRun(i))
+				break;
 			GlyphRun newRun = shaper.runAt(i);
+
 			if (i >= glyphRuns.count())
 				glyphRuns.append(newRun);
 			else
@@ -1464,6 +1470,16 @@
 			bool HasObject = itemText.hasObject(a);
 			PageItem* currentObject = itemText.object(a);
 			bool HasMark = itemText.hasMark(a);
+
+			// set StartOfLine
+			if (current.isEmpty)
+			{
+				glyphRuns[i].setFlag(ScLayout_StartOfLine);
+			}
+			else
+			{
+				glyphRuns[i].clearFlag(ScLayout_StartOfLine);
+			}
 
 			const StyleFlag& effects = itemText.charStyle(a).effects();
 			if (effects & ScStyle_UnderlineWords)
@@ -1662,15 +1678,6 @@
 					chs = qRound((currentObject->height() + currentObject->lineWidth()) * 10);
 				else
 					chs = charStyle.fontSize();
-			}
-			// set StartOfLine
-			if (current.isEmpty)
-			{
-				glyphRuns[i].setFlag(ScLayout_StartOfLine);
-			}
-			else
-			{
-				glyphRuns[i].clearFlag(ScLayout_StartOfLine);
 			}
 //			glyphs->yadvance = 0;
 

Modified: trunk/Scribus/scribus/text/textshaper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21240&path=/trunk/Scribus/scribus/text/textshaper.cpp
==============================================================================
--- trunk/Scribus/scribus/text/textshaper.cpp	(original)
+++ trunk/Scribus/scribus/text/textshaper.cpp	Sun Apr 24 16:15:29 2016
@@ -19,6 +19,7 @@
 	      : m_startIndex(startIndex),
 			m_index(startIndex),
 			m_lastKernedIndex(-1),
+			m_layoutFlags(ScLayout_None),
 			m_item(textItem)
 {
 	if (m_item->lastInFrame() >= m_item->firstInFrame())
@@ -169,6 +170,19 @@
 		m_lastKernedIndex = m_runs.count() - 1;
 }
 
+void TextShaper::startLine(int i)
+{
+	m_layoutFlags = ScLayout_StartOfLine;
+
+	while (m_runs.count() > i)
+	{
+		m_index = m_runs.last().firstChar();
+		m_runs.removeLast();
+	}
+
+	m_lastKernedIndex = m_runs.count() - 1;
+}
+
 void TextShaper::initGlyphLayout(GlyphRun& run, const QString& chars, int runIndex)
 {
 	int a = run.firstChar();
@@ -179,7 +193,9 @@
 	if (SpecialChars::isExpandingSpace(ch))
 		run.setFlag(ScLayout_ExpandingSpace);
 
-	GlyphLayout gl = m_item->layoutGlyphs(runStyle, chars, itemText.flags(a));
+	LayoutFlags layoutFlags = static_cast<LayoutFlags>(itemText.flags(a) | m_layoutFlags);
+	GlyphLayout gl = m_item->layoutGlyphs(runStyle, chars, layoutFlags);
+	m_layoutFlags  = static_cast<LayoutFlags>(m_layoutFlags & (~ScLayout_StartOfLine));
 
 	if (runIndex > 0)
 	{

Modified: trunk/Scribus/scribus/text/textshaper.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21240&path=/trunk/Scribus/scribus/text/textshaper.h
==============================================================================
--- trunk/Scribus/scribus/text/textshaper.h	(original)
+++ trunk/Scribus/scribus/text/textshaper.h	Sun Apr 24 16:15:29 2016
@@ -30,6 +30,11 @@
 	 * Retrieve glyph run at specified index
 	 */
 	GlyphRun runAt(int i);
+
+	/**
+	 * Indicates that a new line is being started
+	 */
+	void startLine(int i);
 	
 protected:
 
@@ -41,6 +46,9 @@
 
 	// Last run which has been kerned
 	int m_lastKernedIndex;
+
+	// Additional flags used for glyph layout
+	LayoutFlags m_layoutFlags;
 	
 	// The item whose text is being shaped
 	PageItem_TextFrame* m_item;




More information about the scribus-commit mailing list