View Issue Details

IDProjectCategoryView StatusLast Update
0016098ScribusTypographypublic2020-05-22 22:17
Reporterftake Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformLinuxOSopenSUSE LeapOS Version15.2
Product Version1.5.6.svn 
Target VersionFixed in Version 
Summary0016098: A white space width become too small when two Latin words are surrounded by CJK characters in a justified paragraph
DescriptionWhen a justified paragraph have a texts like "オープンソースのDesktop Publishingソフトウェア" and line wrap happens, the width of the space become too small. What is strange, adding a space after "Publishing" makes the texts rendered well.

It seems that there are some problems with calculating text width.
Steps To ReproduceSee the files attached.
TagsNo tags attached.
PatchNo

Activities

ftake

2020-04-27 07:38

reporter  

too-small-space-surrounded-by-CJK.sla (17,442 bytes)

ftake

2020-05-15 14:01

reporter   ~0047620

It seems that there is a problem when backing to the previous breakable place. Suppose that we have text like
あいうえおかき|くけこ
where | represents the right end of text frame.

While handling "く" (i = 7), it should go back to "き" (i = 6) and add a new line.

```
i = current.breakIndex;
```

However, since it updates current.breakIndex to 7 before handling line wrap, it cannot go back to 6.

ftake

2020-05-16 15:27

reporter   ~0047622

# please remove note 47621

It seems that basic line wrapping was broken regardless of justification mode.

To resolve this problem, I moved code snippets remembering possible breaks so that it can be executed after checking the last glyph can be pushed into the current line (not "out" of frame).

I am not sure this fix works perfectly.

fix-16098-2.patch (2,671 bytes)
commit 7c0ee2fe79e2c651ed7b042b227c3368d8bc8ed6
Author: Fuminobu TAKEYAMA <ftake@geeko.jp>
Date:   Sun May 17 00:13:26 2020 +0900

    #16098: remember a line break position only when the last glyph can be pushed
    into the current line

diff --git a/scribus/pageitem_textframe.cpp b/scribus/pageitem_textframe.cpp
index 6d3202cc6..65059f87c 100644
--- a/scribus/pageitem_textframe.cpp
+++ b/scribus/pageitem_textframe.cpp
@@ -2172,28 +2172,6 @@ void PageItem_TextFrame::layout()
 			{
 				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))
@@ -2807,6 +2785,33 @@ void PageItem_TextFrame::layout()
 					}
 				}
 			}
+			else
+			{
+				// not out
+				// remember possible break after this glyph
+				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, current.xPos, style.rightMargin());
+						}
+					}
+				}
+				if (HasObject)
+				{
+	//				qDebug() << "rememberBreak object @" << i;
+					current.rememberBreak(i, current.xPos, style.rightMargin());
+				}
+			}
+
 			if (!shapedText.haveMoreText(i + 1, glyphClusters))
 			{
 				if (!current.afterOverflow || current.addLine)
fix-16098-2.patch (2,671 bytes)

ftake

2020-05-22 15:02

reporter   ~0047632

@jghali Could you check this patch?

jghali

2020-05-22 22:17

administrator   ~0047633

@ftake, I'll look at it later, I'm working on some new stuff right now.

Issue History

Date Modified Username Field Change
2020-04-27 07:38 ftake New Issue
2020-04-27 07:38 ftake File Added: too-small-space-surrounded-by-CJK.png
2020-04-27 07:38 ftake File Added: too-small-space-surrounded-by-CJK.sla
2020-05-15 14:01 ftake Note Added: 0047620
2020-05-16 15:17 ftake File Added: fix-16098.patch
2020-05-16 15:27 ftake File Added: fix-16098-2.patch
2020-05-16 15:27 ftake Note Added: 0047622
2020-05-16 15:28 ftake File Deleted: fix-16098.patch
2020-05-22 15:02 ftake Note Added: 0047632
2020-05-22 22:17 jghali Note Added: 0047633