r25075 by jghali - #16098: A white space width become too small when two Latin words are surrounded by CJK characters in a justified paragraph <ftake>

scribus-commit scribus-commit at lists.scribus.net
Tue Apr 12 21:11:48 UTC 2022


Author: jghali
Date: Tue Apr 12 21:11:47 2022
New Revision: 25075

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25075
Log:
#16098: A white space width become too small when two Latin words are surrounded by CJK characters in a justified paragraph <ftake>

Modified:
    branches/Version15x/Scribus/scribus/pageitem_textframe.cpp

Modified: branches/Version15x/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25075&path=/branches/Version15x/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- branches/Version15x/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ branches/Version15x/Scribus/scribus/pageitem_textframe.cpp	Tue Apr 12 21:11:47 2022
@@ -2115,28 +2115,6 @@
 			{
 				current.xPos = qMax(current.xPos, current.colLeft);
 			}
-			// remember possible break
-			if (shapedText.haveMoreText(i + 1, glyphClusters))
-			{
-				const GlyphCluster& nextCluster = glyphClusters[i + 1];
-				if (nextCluster.hasFlag(ScLayout_LineBoundary))
-				{
-					// #16100: why preventing possible line break when there are two
-					// consecutive line break opportunities? This is bad for CJK. /
-					if (/*!current.glyphs[currentIndex].hasFlag(ScLayout_LineBoundary)
-						&&*/ !current.glyphs[currentIndex].hasFlag(ScLayout_HyphenationPossible)
-						&& (itemText.text(a) != '-')
-						&& (itemText.text(a) != SpecialChars::SHYPHEN))
-					{
-						current.rememberBreak(i, breakPos, style.rightMargin());
-					}
-				}
-			}
-			if (HasObject)
-			{
-//				qDebug() << "rememberBreak object @" << i;
-				current.rememberBreak(i, breakPos, style.rightMargin());
-			}
 
 			//check against space before PARSEP
 			/*if (SpecialChars::isBreakingSpace(hl->ch) && (a + 1 < itemText.length()) && (itemText.item(a + 1)->ch == SpecialChars::PARSEP))
@@ -2495,6 +2473,13 @@
 				}
 				else // outs -- last char went outside the columns (or into flow-around shape)
 				{
+					// #16098 only if the last char can hang at the edge,
+					// add line break after this char.
+					// for now, such chars is only spaces but may change in the future
+					// e.g. https://www.w3.org/TR/css-text-3/#hanging
+					if (itemText.text(a).isSpace()) {
+						current.rememberBreak(i, breakPos, style.rightMargin());
+					}
 					if (current.breakIndex >= 0)
 					{
 						// go back to last break position
@@ -2741,6 +2726,33 @@
 							++m_maxChars;
 						goto NoRoom;
 					}
+				}
+			}
+			else // if (outs)
+			{
+				// moved here to fix #16098
+				// remember possible break only when the current char is not placed on the edge.
+				// white space / character hanging is not treated here anymore
+				if (shapedText.haveMoreText(i + 1, glyphClusters))
+				{
+					const GlyphCluster& nextCluster = glyphClusters[i + 1];
+					if (nextCluster.hasFlag(ScLayout_LineBoundary))
+					{
+						// #16100: why preventing possible line break when there are two
+						// consecutive line break opportunities? This is bad for CJK. /
+						if (/*!current.glyphs[currentIndex].hasFlag(ScLayout_LineBoundary)
+							&&*/ !current.glyphs[currentIndex].hasFlag(ScLayout_HyphenationPossible)
+							&& (itemText.text(a) != '-')
+							&& (itemText.text(a) != SpecialChars::SHYPHEN))
+						{
+							current.rememberBreak(i, breakPos, style.rightMargin());
+						}
+					}
+				}
+				if (HasObject)
+				{
+//					qDebug() << "rememberBreak object @" << i;
+					current.rememberBreak(i, breakPos, style.rightMargin());
 				}
 			}
 			if (!shapedText.haveMoreText(i + 1, glyphClusters))




More information about the scribus-commit mailing list