r22178 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Mon Oct 2 18:37:59 UTC 2017


Author: jghali
Date: Mon Oct  2 18:37:59 2017
New Revision: 22178

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22178
Log:
fix incorrect use of SpecialChars::CJK_NOBREAK_AFTER and SpecialChars::CJK_NOBREAK_BEFORE in layout()

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

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22178&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Mon Oct  2 18:37:59 2017
@@ -2244,19 +2244,17 @@
 				current.xPos = qMax(current.xPos, current.colLeft);
 			}
 			// remember possible break
-			if (shapedText.haveMoreText(i + 1, glyphClusters) && glyphClusters[i + 1].hasFlag(ScLayout_LineBoundary))
-			{
-				if (current.glyphs.length() > 1
-					&& (current.glyphs[currentIndex - 1].lastChar() != SpecialChars::CJK_NOBREAK_AFTER)
-					&& (current.glyphs[currentIndex].firstChar() != SpecialChars::CJK_NOBREAK_BEFORE))
-				{
-//					qDebug() << "rememberBreak LineBoundry @" << i-1;
-					current.rememberBreak(i - 1, breakPos, style.rightMargin());
-				}
-				if (!current.glyphs[currentIndex].hasFlag(ScLayout_LineBoundary))
-				{
-//					qDebug() << "rememberBreak 2nd LineBoundry @" << i;
-					current.rememberBreak(i, breakPos, style.rightMargin());
+			if (shapedText.haveMoreText(i + 1, glyphClusters))
+			{
+				const GlyphCluster& nextCluster = glyphClusters[i + 1];
+				if (nextCluster.hasFlag(ScLayout_LineBoundary))
+				{
+					if (!current.glyphs[currentIndex].hasFlag(ScLayout_HyphenationPossible)
+						&& (itemText.text(a) != '-')
+						&& (itemText.text(a) != SpecialChars::SHYPHEN))
+					{
+						current.rememberBreak(i, breakPos, style.rightMargin());
+					}
 				}
 			}
 			if (HasObject)

Modified: trunk/Scribus/scribus/sctextstruct.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22178&path=/trunk/Scribus/scribus/sctextstruct.h
==============================================================================
--- trunk/Scribus/scribus/sctextstruct.h	(original)
+++ trunk/Scribus/scribus/sctextstruct.h	Mon Oct  2 18:37:59 2017
@@ -54,7 +54,9 @@
 	ScLayout_RightToLeft      = 1 << 17,     // marks right-to-left glyph
 	ScLayout_SmallCap         = 1 << 18,     // marks small caps glyph
 	ScLayout_CJKFence         = 1 << 19,     // marks CJK fence glyph that needs spacing adjustment at start of line
-	ScLayout_JustificationTracking = 1 << 20 // marks place of tracking in justification (e.g. for Thai)
+	ScLayout_NoBreakAfter     = 1 << 20,     // marks glyphs after which a line break cannot occur
+	ScLayout_NoBreakBefore    = 1 << 21,     // marks glyphs before which a line break cannot occur
+	ScLayout_JustificationTracking = 1 << 22 // marks place of tracking in justification (e.g. for Thai)
 };
 
 

Modified: trunk/Scribus/scribus/text/textshaper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22178&path=/trunk/Scribus/scribus/text/textshaper.cpp
==============================================================================
--- trunk/Scribus/scribus/text/textshaper.cpp	(original)
+++ trunk/Scribus/scribus/text/textshaper.cpp	Mon Oct  2 18:37:59 2017
@@ -411,6 +411,22 @@
 			    SpecialChars::isCJK(m_story.text(firstChar - 1).unicode()))
 				run.setFlag(ScLayout_ImplicitSpace);
 
+			int firstStat = SpecialChars::getCJKAttr(m_story.text(firstChar));
+			int currStat  = (firstChar != lastChar) ? SpecialChars::getCJKAttr(m_story.text(lastChar)) : firstStat;
+
+			if (firstStat & SpecialChars::CJK_NOBREAK_BEFORE)
+				run.setFlag(ScLayout_NoBreakBefore);
+
+			if (currStat & SpecialChars::CJK_NOBREAK_AFTER)
+				run.setFlag(ScLayout_NoBreakAfter);
+
+			if ((firstChar > 0) && (firstStat != 0) && ((firstStat & SpecialChars::CJK_NOBREAK_BEFORE) == 0))
+			{
+				int prevStat = SpecialChars::getCJKAttr(m_story.text(firstChar - 1));
+				if (prevStat != 0 && ((prevStat & SpecialChars::CJK_NOBREAK_AFTER) == 0))
+					run.setFlag(ScLayout_LineBoundary);
+			}
+
 			run.setScaleH(charStyle.scaleH() / 1000.0);
 			run.setScaleV(charStyle.scaleV() / 1000.0);
 
@@ -503,7 +519,6 @@
 				double halfEM = run.style().fontSize() / 10 / 2;
 				double quarterEM = run.style().fontSize() / 10 / 4;
 
-				int currStat = SpecialChars::getCJKAttr(m_story.text(lastChar));
 				int nextStat = SpecialChars::getCJKAttr(m_story.text(lastChar + 1));
 
 				// 1. add 1/4 aki (space) between a CJK letter and




More information about the scribus-commit mailing list