View Issue Details

IDProjectCategoryView StatusLast Update
0016100ScribusTypographypublic2020-08-11 20:56
Reporterftake Assigned Tojghali  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.5.6.svn 
Fixed in Version1.5.6.svn 
Summary0016100: No line wrap between a CJK character and a Latin character (after a CJK)
DescriptionIt seems that line wrap does not happens between a CJK character and a Latin character (only when a Latin character follows after a CJK character).

As far as I inspected by using debugger, `lineBreaks` provides correct places for line wrap and "s" of something (see the picture attached) have the `ScLayout_LineBoundary` flag.


Note that:
The code snippets using SpecialChars::CJK_NOBREAK_BEFORE and SpecialChars::CJK_NOBREAK_AFTER seems to be dead. I need more investigation libicu supports all the cases those snippets implemented.
TagsNo tags attached.
PatchNo

Activities

ftake

2020-04-28 09:41

reporter  

no-line-break-after-CJK.png (112,536 bytes)   
no-line-break-after-CJK.png (112,536 bytes)   
no-line-break-after-CJK.sla (15,578 bytes)   
<?xml version="1.0" encoding="UTF-8"?>
<SCRIBUSUTF8NEW Version="1.5.6.svn">
    <DOCUMENT ANZPAGES="1" PAGEWIDTH="595.275590551181" PAGEHEIGHT="841.889763779528" BORDERLEFT="40" BORDERRIGHT="40" BORDERTOP="40" BORDERBOTTOM="40" PRESET="0" BleedTop="0" BleedLeft="0" BleedRight="0" BleedBottom="0" ORIENTATION="0" PAGESIZE="A4" FIRSTNUM="1" BOOK="0" AUTOSPALTEN="1" ABSTSPALTEN="11" UNITS="1" DFONT="Open Sans Regular" DSIZE="12" DCOL="1" DGAP="0" TabFill="" TabWidth="36" TextDistLeft="0" TextDistRight="0" TextDistBottom="0" TextDistTop="0" AUTHOR="" COMMENTS="" KEYWORDS="" PUBLISHER="" DOCDATE="" DOCTYPE="" DOCFORMAT="" DOCIDENT="" DOCSOURCE="" DOCLANGINFO="" DOCRELATION="" DOCCOVER="" DOCRIGHTS="" DOCCONTRIB="" TITLE="" SUBJECT="" VHOCH="33" VHOCHSC="66" VTIEF="33" VTIEFSC="66" VKAPIT="75" BASEGRID="14.4" BASEO="0" AUTOL="100" UnderlinePos="-1" UnderlineWidth="-1" StrikeThruPos="-1" StrikeThruWidth="-1" GROUPC="1" HCMS="1" DPSo="0" DPSFo="0" DPuse="1" DPgam="0" DPbla="1" DPPr="Fogra27L CMYK Coated Press" DPIn="sRGB IEC61966-2.1" DPInCMYK="Fogra27L CMYK Coated Press" DPIn2="sRGB IEC61966-2.1" DPIn3="Fogra27L CMYK Coated Press" DISc="1" DIIm="0" ALAYER="0" LANGUAGE="ja" AUTOMATIC="1" AUTOCHECK="0" GUIDELOCK="0" SnapToGuides="0" SnapToGrid="0" SnapToElement="0" MINGRID="20.001" MAJGRID="100.001" SHOWGRID="0" SHOWGUIDES="1" showcolborders="1" SHOWFRAME="1" SHOWControl="1" SHOWLAYERM="0" SHOWMARGIN="1" SHOWBASE="0" SHOWPICT="1" SHOWLINK="0" rulerMode="1" showrulers="1" showBleed="1" rulerXoffset="0" rulerYoffset="0" GuideRad="10" GRAB="4" POLYC="4" POLYF="0.502" POLYR="0" POLYIR="0" POLYCUR="0" POLYOCUR="0" POLYS="0" arcStartAngle="30" arcSweepAngle="300" spiralStartAngle="0" spiralEndAngle="1080" spiralFactor="1.2" AutoSave="1" AutoSaveTime="600000" AutoSaveCount="1" AutoSaveKeep="0" AUtoSaveInDocDir="1" AutoSaveDir="" ScratchBottom="20.001" ScratchLeft="100.001" ScratchRight="100.001" ScratchTop="20.001" GapHorizontal="0" GapVertical="40" StartArrow="0" EndArrow="0" PEN="Black" BRUSH="None" PENLINE="Black" PENTEXT="Black" StrokeText="Black" TextBackGround="None" TextLineColor="None" TextBackGroundShade="100" TextLineShade="100" TextPenShade="100" TextStrokeShade="100" STIL="1" STILLINE="1" WIDTH="1" WIDTHLINE="1" PENSHADE="100" LINESHADE="100" BRUSHSHADE="100" CPICT="None" PICTSHADE="100" CSPICT="None" PICTSSHADE="100" PICTSCX="1" PICTSCY="1" PSCALE="1" PASPECT="1" EmbeddedPath="0" HalfRes="1" dispX="10.001" dispY="10.001" constrain="15" MINORC="#00ff00" MAJORC="#00ff00" GuideC="#000080" BaseC="#c0c0c0" renderStack="2 0 4 1 3" GridType="0" PAGEC="#ffffff" MARGC="#0000ff" RANDF="0" currentProfile="PDF 1.4" calligraphicPenFillColor="Black" calligraphicPenLineColor="Black" calligraphicPenFillColorShade="100" calligraphicPenLineColorShade="100" calligraphicPenLineWidth="1" calligraphicPenAngle="0" calligraphicPenWidth="10" calligraphicPenStyle="1">
        <CheckProfile Name="PDF 1.3" ignoreErrors="0" autoCheck="1" checkGlyphs="1" checkOrphans="1" checkOverflow="1" checkPictures="1" checkPartFilledImageFrames="0" checkResolution="1" checkTransparency="1" minResolution="144" maxResolution="2400" checkAnnotations="0" checkRasterPDF="1" checkForGIF="1" ignoreOffLayers="0" checkNotCMYKOrSpot="0" checkDeviceColorsAndOutputIntent="0" checkFontNotEmbedded="1" checkFontIsOpenType="1" checkAppliedMasterDifferentSide="1" checkEmptyTextFrames="1"/>
        <CheckProfile Name="PDF 1.4" ignoreErrors="0" autoCheck="1" checkGlyphs="1" checkOrphans="1" checkOverflow="1" checkPictures="1" checkPartFilledImageFrames="0" checkResolution="1" checkTransparency="0" minResolution="144" maxResolution="2400" checkAnnotations="0" checkRasterPDF="1" checkForGIF="1" ignoreOffLayers="0" checkNotCMYKOrSpot="0" checkDeviceColorsAndOutputIntent="0" checkFontNotEmbedded="1" checkFontIsOpenType="1" checkAppliedMasterDifferentSide="1" checkEmptyTextFrames="1"/>
        <CheckProfile Name="PDF 1.5" ignoreErrors="0" autoCheck="1" checkGlyphs="1" checkOrphans="1" checkOverflow="1" checkPictures="1" checkPartFilledImageFrames="0" checkResolution="1" checkTransparency="0" minResolution="144" maxResolution="2400" checkAnnotations="0" checkRasterPDF="1" checkForGIF="1" ignoreOffLayers="0" checkNotCMYKOrSpot="0" checkDeviceColorsAndOutputIntent="0" checkFontNotEmbedded="1" checkFontIsOpenType="1" checkAppliedMasterDifferentSide="1" checkEmptyTextFrames="1"/>
        <CheckProfile Name="PDF 1.6" ignoreErrors="0" autoCheck="1" checkGlyphs="1" checkOrphans="1" checkOverflow="1" checkPictures="1" checkPartFilledImageFrames="0" checkResolution="1" checkTransparency="0" minResolution="144" maxResolution="2400" checkAnnotations="0" checkRasterPDF="1" checkForGIF="1" ignoreOffLayers="0" checkNotCMYKOrSpot="0" checkDeviceColorsAndOutputIntent="0" checkFontNotEmbedded="1" checkFontIsOpenType="0" checkAppliedMasterDifferentSide="1" checkEmptyTextFrames="1"/>
        <CheckProfile Name="PDF/X-1a" ignoreErrors="0" autoCheck="1" checkGlyphs="1" checkOrphans="1" checkOverflow="1" checkPictures="1" checkPartFilledImageFrames="0" checkResolution="1" checkTransparency="1" minResolution="144" maxResolution="2400" checkAnnotations="1" checkRasterPDF="1" checkForGIF="1" ignoreOffLayers="0" checkNotCMYKOrSpot="1" checkDeviceColorsAndOutputIntent="0" checkFontNotEmbedded="1" checkFontIsOpenType="1" checkAppliedMasterDifferentSide="1" checkEmptyTextFrames="1"/>
        <CheckProfile Name="PDF/X-3" ignoreErrors="0" autoCheck="1" checkGlyphs="1" checkOrphans="1" checkOverflow="1" checkPictures="1" checkPartFilledImageFrames="0" checkResolution="1" checkTransparency="1" minResolution="144" maxResolution="2400" checkAnnotations="1" checkRasterPDF="1" checkForGIF="1" ignoreOffLayers="0" checkNotCMYKOrSpot="0" checkDeviceColorsAndOutputIntent="1" checkFontNotEmbedded="1" checkFontIsOpenType="1" checkAppliedMasterDifferentSide="1" checkEmptyTextFrames="1"/>
        <CheckProfile Name="PDF/X-4" ignoreErrors="0" autoCheck="1" checkGlyphs="1" checkOrphans="1" checkOverflow="1" checkPictures="1" checkPartFilledImageFrames="0" checkResolution="1" checkTransparency="0" minResolution="144" maxResolution="2400" checkAnnotations="1" checkRasterPDF="1" checkForGIF="1" ignoreOffLayers="0" checkNotCMYKOrSpot="0" checkDeviceColorsAndOutputIntent="1" checkFontNotEmbedded="1" checkFontIsOpenType="0" checkAppliedMasterDifferentSide="1" checkEmptyTextFrames="1"/>
        <CheckProfile Name="PostScript" ignoreErrors="0" autoCheck="1" checkGlyphs="1" checkOrphans="1" checkOverflow="1" checkPictures="1" checkPartFilledImageFrames="0" checkResolution="1" checkTransparency="1" minResolution="144" maxResolution="2400" checkAnnotations="0" checkRasterPDF="1" checkForGIF="1" ignoreOffLayers="0" checkNotCMYKOrSpot="0" checkDeviceColorsAndOutputIntent="0" checkFontNotEmbedded="0" checkFontIsOpenType="0" checkAppliedMasterDifferentSide="1" checkEmptyTextFrames="1"/>
        <COLOR NAME="Black" SPACE="CMYK" C="0" M="0" Y="0" K="100"/>
        <COLOR NAME="Registration" SPACE="CMYK" C="100" M="100" Y="100" K="100" Register="1"/>
        <COLOR NAME="White" SPACE="CMYK" C="0" M="0" Y="0" K="0"/>
        <HYPHEN/>
        <STYLE NAME="Default Paragraph Style" DefaultStyle="1" ALIGN="0" DIRECTION="0" LINESPMode="0" LINESP="15" INDENT="0" RMARGIN="0" FIRST="0" VOR="0" NACH="0" ParagraphEffectOffset="0" DROP="0" DROPLIN="2" Bullet="0" Numeration="0" HyphenConsecutiveLines="2" BCOLOR="None" BSHADE="100"/>
        <CHARSTYLE CNAME="Default Character Style" DefaultStyle="1" FONT="Open Sans Regular" FONTSIZE="12" FONTFEATURES="" FEATURES="inherit" FCOLOR="Black" FSHADE="100" HyphenWordMin="3" SCOLOR="Black" BGCOLOR="None" BGSHADE="100" SSHADE="100" TXTSHX="5" TXTSHY="-5" TXTOUT="1" TXTULP="-0.1" TXTULW="-0.1" TXTSTP="-0.1" TXTSTW="-0.1" SCALEH="100" SCALEV="100" BASEO="0" KERN="0" LANGUAGE="ja"/>
        <TableStyle NAME="Default Table Style" DefaultStyle="1" FillColor="None" FillShade="100">
            <TableBorderLeft>
                <TableBorderLine Width="1" PenStyle="1" Color="Black" Shade="100"/>
            </TableBorderLeft>
            <TableBorderRight>
                <TableBorderLine Width="1" PenStyle="1" Color="Black" Shade="100"/>
            </TableBorderRight>
            <TableBorderTop>
                <TableBorderLine Width="1" PenStyle="1" Color="Black" Shade="100"/>
            </TableBorderTop>
            <TableBorderBottom>
                <TableBorderLine Width="1" PenStyle="1" Color="Black" Shade="100"/>
            </TableBorderBottom>
        </TableStyle>
        <CellStyle NAME="Default Cell Style" DefaultStyle="1" FillColor="None" FillShade="100" LeftPadding="1" RightPadding="1" TopPadding="1" BottomPadding="1">
            <TableBorderLeft>
                <TableBorderLine Width="1" PenStyle="1" Color="Black" Shade="100"/>
            </TableBorderLeft>
            <TableBorderRight>
                <TableBorderLine Width="1" PenStyle="1" Color="Black" Shade="100"/>
            </TableBorderRight>
            <TableBorderTop>
                <TableBorderLine Width="1" PenStyle="1" Color="Black" Shade="100"/>
            </TableBorderTop>
            <TableBorderBottom>
                <TableBorderLine Width="1" PenStyle="1" Color="Black" Shade="100"/>
            </TableBorderBottom>
        </CellStyle>
        <LAYERS NUMMER="0" LEVEL="0" NAME="Background" SICHTBAR="1" DRUCKEN="1" EDIT="1" SELECT="0" FLOW="1" TRANS="1" BLEND="0" OUTL="0" LAYERC="#000000"/>
        <Printer firstUse="1" toFile="0" useAltPrintCommand="0" outputSeparations="0" useSpotColors="0" useColor="0" mirrorH="0" mirrorV="0" useICC="1" doGCR="1" doClip="0" setDevParam="0" useDocBleeds="0" cropMarks="0" bleedMarks="0" registrationMarks="0" colorMarks="0" includePDFMarks="1" PSLevel="3" PDLanguage="3" markLength="1.18575755001899e-322" markOffset="1.02359984249158e-306" BleedTop="0" BleedLeft="0" BleedRight="0" BleedBottom="0" printer="" filename="" separationName="" printerCommand=""/>
        <PDF firstUse="1" Thumbnails="0" Articles="0" Bookmarks="0" Compress="1" CMethod="0" Quality="0" EmbedPDF="0" MirrorH="0" MirrorV="0" Clip="0" rangeSel="0" rangeTxt="" RotateDeg="0" PresentMode="0" RecalcPic="0" FontEmbedding="0" Grayscale="0" RGBMode="1" UseProfiles="0" UseProfiles2="0" Binding="0" PicRes="300" Resolution="300" Version="14" Intent="1" Intent2="0" SolidP="sRGB IEC61966-2.1" ImageP="sRGB IEC61966-2.1" PrintP="Fogra27L CMYK Coated Press" InfoString="" BTop="0" BLeft="0" BRight="0" BBottom="0" useDocBleeds="1" cropMarks="0" bleedMarks="0" registrationMarks="0" colorMarks="0" docInfoMarks="0" markLength="20.0012598425197" markOffset="0" ImagePr="0" PassOwner="" PassUser="" Permissions="-4" Encrypt="0" UseLayers="0" UseLpi="0" UseSpotColors="1" doMultiFile="0" displayBookmarks="0" displayFullscreen="0" displayLayers="0" displayThumbs="0" hideMenuBar="0" hideToolBar="0" fitWindow="0" openAfterExport="0" PageLayout="0" openAction="">
            <LPI Color="" Frequency="0" Angle="0" SpotFunction="0"/>
            <LPI Color="Black" Frequency="133" Angle="45" SpotFunction="3"/>
            <LPI Color="Cyan" Frequency="133" Angle="105" SpotFunction="3"/>
            <LPI Color="Magenta" Frequency="133" Angle="75" SpotFunction="3"/>
            <LPI Color="Yellow" Frequency="133" Angle="90" SpotFunction="3"/>
        </PDF>
        <DocItemAttributes/>
        <TablesOfContents/>
        <NotesStyles>
            <notesStyle Name="Default" Start="1" Endnotes="0" Type="Type_1_2_3" Range="0" Prefix="" Suffix=")" AutoHeight="1" AutoWidth="1" AutoRemove="1" AutoWeld="1" SuperNote="1" SuperMaster="1" MarksStyle="" NotesStyle=""/>
        </NotesStyles>
        <NotesFrames/>
        <PageSets>
            <Set Name="Single Page" FirstPage="0" Rows="1" Columns="1"/>
            <Set Name="Facing Pages" FirstPage="1" Rows="1" Columns="2">
                <PageNames Name="Left Page"/>
                <PageNames Name="Right Page"/>
            </Set>
            <Set Name="3-Fold" FirstPage="0" Rows="1" Columns="3">
                <PageNames Name="Left Page"/>
                <PageNames Name="Middle"/>
                <PageNames Name="Right Page"/>
            </Set>
            <Set Name="4-Fold" FirstPage="0" Rows="1" Columns="4">
                <PageNames Name="Left Page"/>
                <PageNames Name="Middle Left"/>
                <PageNames Name="Middle Right"/>
                <PageNames Name="Right Page"/>
            </Set>
        </PageSets>
        <Sections>
            <Section Number="0" Name="0" From="0" To="0" Type="Type_1_2_3" Start="1" Reversed="0" Active="1" FillChar="0" FieldWidth="0"/>
        </Sections>
        <MASTERPAGE PAGEXPOS="100.001" PAGEYPOS="20.001" PAGEWIDTH="595.275590551181" PAGEHEIGHT="841.889763779528" BORDERLEFT="40" BORDERRIGHT="40" BORDERTOP="40" BORDERBOTTOM="40" NUM="0" NAM="Normal" MNAM="" Size="A4" Orientation="0" LEFT="0" PRESET="0" VerticalGuides="" HorizontalGuides="" AGhorizontalAutoGap="0" AGverticalAutoGap="0" AGhorizontalAutoCount="0" AGverticalAutoCount="0" AGhorizontalAutoRefer="0" AGverticalAutoRefer="0" AGSelection="0 0 0 0" pageEffectDuration="1" pageViewDuration="1" effectType="0" Dm="0" M="0" Di="0"/>
        <PAGE PAGEXPOS="100.001" PAGEYPOS="20.001" PAGEWIDTH="595.275590551181" PAGEHEIGHT="841.889763779528" BORDERLEFT="40" BORDERRIGHT="40" BORDERTOP="40" BORDERBOTTOM="40" NUM="0" NAM="" MNAM="Normal" Size="A4" Orientation="0" LEFT="0" PRESET="0" VerticalGuides="" HorizontalGuides="" AGhorizontalAutoGap="0" AGverticalAutoGap="0" AGhorizontalAutoCount="0" AGverticalAutoCount="0" AGhorizontalAutoRefer="0" AGverticalAutoRefer="0" AGSelection="0 0 0 0" pageEffectDuration="1" pageViewDuration="1" effectType="0" Dm="0" M="0" Di="0"/>
        <PAGEOBJECT XPOS="143" YPOS="178" OwnPage="0" ItemID="91934288" PTYPE="4" WIDTH="185" HEIGHT="107" FRTYPE="0" CLIPEDIT="0" PWIDTH="1" PLINEART="1" LOCALSCX="1" LOCALSCY="1" LOCALX="0" LOCALY="0" LOCALROT="0" PICART="1" SCALETYPE="1" RATIO="1" COLUMNS="1" COLGAP="0" AUTOTEXT="0" EXTRA="0" TEXTRA="0" BEXTRA="0" REXTRA="0" VAlign="0" FLOP="0" PLTSHOW="0" BASEOF="0" textPathType="0" textPathFlipped="0" path="M0 0 L185 0 L185 107 L0 107 L0 0 Z" copath="M0 0 L185 0 L185 107 L0 107 L0 0 Z" gXpos="143" gYpos="178" gWidth="0" gHeight="0" ALIGN="3" LAYER="0" NEXTITEM="-1" BACKITEM="-1">
            <StoryText>
                <DefaultStyle ALIGN="3" LINESPMode="1" FONT="Noto Sans CJK JP Regular" LANGUAGE="ja"/>
                <ITEXT FONT="Noto Sans CJK JP Regular" LANGUAGE="ja" CH="aaaaaaaaaaaaaaaaaabbと絵"/>
                <ITEXT LANGUAGE="ja" CH="something あいうthis thatえお あああ"/>
                <trail ALIGN="0"/>
            </StoryText>
        </PAGEOBJECT>
        <PAGEOBJECT XPOS="166" YPOS="321" OwnPage="0" ItemID="99965104" PTYPE="4" WIDTH="495" HEIGHT="113" FRTYPE="0" CLIPEDIT="0" PWIDTH="1" PLINEART="1" LOCALSCX="1" LOCALSCY="1" LOCALX="0" LOCALY="0" LOCALROT="0" PICART="1" SCALETYPE="1" RATIO="1" COLUMNS="1" COLGAP="0" AUTOTEXT="0" EXTRA="0" TEXTRA="0" BEXTRA="0" REXTRA="0" VAlign="0" FLOP="0" PLTSHOW="0" BASEOF="0" textPathType="0" textPathFlipped="0" path="M0 0 L495 0 L495 113 L0 113 L0 0 Z" copath="M0 0 L495 0 L495 113 L0 113 L0 0 Z" gXpos="166" gYpos="321" gWidth="0" gHeight="0" LAYER="0" NEXTITEM="-1" BACKITEM="-1">
            <StoryText>
                <DefaultStyle/>
                <ITEXT CH="Line Breaks:  QVector(0, 20, 21, 22, 32, 33, 34, 35, 40, 44, 45, 47, 48, 49, 50)"/>
                <trail/>
            </StoryText>
        </PAGEOBJECT>
    </DOCUMENT>
</SCRIBUSUTF8NEW>
no-line-break-after-CJK.sla (15,578 bytes)   

jghali

2020-04-29 13:46

administrator   ~0047580

The issue is at line 2418 of pageitem_textframe.cpp:
if (i != 0 && implicitBreak(itemText.text(glyphClusters[i - 1].lastChar()), itemText.text(current.glyphs[currentIndex].firstChar())))
The implicitBreak() function does not consider the cases of latin character following CJK character or CJK character following latin character.

A quick fix is to replace the condition by:
if (i != 0 && current.glyphs[currentIndex].hasFlag(ScLayout_LineBoundary))
However I'm not sure it will not break the handling of consecutive hyphens.

Quick related question : does SpecialChars::CJK_NOBREAK_AFTER needs to be considered in the case of a CJK character followed by a latin character? Same question for SpecialChars::CJK_NOBREAK_BEFORE : does SpecialChars::CJK_NOBREAK_BEFORE needs to be considered in the case of a CJK character preceded by a latin character.

jghali

2020-04-29 13:53

administrator   ~0047581

>> The code snippets using SpecialChars::CJK_NOBREAK_BEFORE and SpecialChars::CJK_NOBREAK_AFTER seems to be dead. I need more investigation libicu supports all the cases those snippets implemented.

Yes, I am also thinking that a least some of this code could be removed as we are now using icu for getting possible line boundaries.

ftake

2020-04-30 15:09

reporter   ~0047587

Oh, CJK line break rules implemented in textshaper.c and specialchars.c are overridden by pageitem_textframe.c

> A quick fix is to replace the condition by:
> if (i != 0 && current.glyphs[currentIndex].hasFlag(ScLayout_LineBoundary))

I have not fully understand yet but I guess we miss "else if" in the following if blocks:

```
// remember possible break
if (shapedText.haveMoreText(i + 1, glyphClusters))
{
    const GlyphCluster& nextCluster = glyphClusters[i + 1];
    if (nextCluster.hasFlag(ScLayout_LineBoundary))
    {
        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());
        }
    }
}
```

> does SpecialChars::CJK_NOBREAK_AFTER needs to be considered in the case of a CJK character followed by a latin character?

Yes. For example, in "「abcd」", "「" has CJK_NOBREAK_AFTER and no line break should happen between "「" and "abcd". Of course, libicu supports this kind of rules.

> Yes, I am also thinking that a least some of this code could be removed as we are now using icu for getting possible line boundaries.

I noticed a limitation of the current Scribus implimentation. libicu provides three line break strictness [1]. The original code in specialchars.c seems to be the strict mode. For example, 「っ」has NO_BREAK_AFTER but the normal mode of libicu returns that character is breakable.

For now, Scribus does not specify strictness, so the current mode seems to be sicked to the normal mode. Since the normal mode is suitable for some cases, it would be great if we can change the strictness from Scribus's character style.

[1] http://userguide.icu-project.org/boundaryanalysis#TOC-Line-Breaking-Strictness-a-CSS-Property

We can set strictness by the argument of Locale.

```
m_lineIterator = BreakIterator::createLineInstance(Locale("ja@lb=strict"), status);
```

jghali

2020-05-01 19:50

administrator   ~0047588

I have done more investigation and it seems the culprit may be in fact the following block of code:
if (nextCluster.hasFlag(ScLayout_LineBoundary))
{
    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());
    }
}

The two conditions explicitly forbid to remember a break opportunity if we have two successive break opportunities. Not sure why. However it is sure that this is not good for CJK and this is in fact what primarily cause this issue. Suppressing the condition related to ScLayout_LineBoundary in second if() *almost* fix it.

The second problem is that the block of code which test implicit chars afterwards remember break on a lower i - 1 value:
if (i != 0 && implicitBreak(itemText.text(glyphClusters[i - 1].lastChar()), itemText.text(current.glyphs[currentIndex].firstChar())))
{
    current.rememberBreak(i - 1, breakPos);
}

After the first block of code has been modified, it seems that this second block of code becomes unnecessary. So I'd just comment it out.

Patch attached. Please test.
16100_no_linebreak_between_cjk_and_latin_chars.patch (1,376 bytes)   
Index: scribus/pageitem_textframe.cpp
===================================================================
--- scribus/pageitem_textframe.cpp	(revision 23676)
+++ scribus/pageitem_textframe.cpp	(working copy)
@@ -2170,8 +2170,8 @@
 				const GlyphCluster& nextCluster = glyphClusters[i + 1];
 				if (nextCluster.hasFlag(ScLayout_LineBoundary))
 				{
-					if (!current.glyphs[currentIndex].hasFlag(ScLayout_LineBoundary)
-						&& !current.glyphs[currentIndex].hasFlag(ScLayout_HyphenationPossible)
+					if (/*!current.glyphs[currentIndex].hasFlag(ScLayout_LineBoundary)
+						&&*/ !current.glyphs[currentIndex].hasFlag(ScLayout_HyphenationPossible)
 						&& (itemText.text(a) != '-')
 						&& (itemText.text(a) != SpecialChars::SHYPHEN))
 					{
@@ -2415,11 +2415,11 @@
 			if ((itemText.text(a) == SpecialChars::COLBREAK) && (m_columns > 1))
 				goNextColumn = true;
 
-			if (i != 0 && implicitBreak(itemText.text(glyphClusters[i - 1].lastChar()), itemText.text(current.glyphs[currentIndex].firstChar())))
+			/*if (i != 0 && implicitBreak(itemText.text(glyphClusters[i - 1].lastChar()), itemText.text(current.glyphs[currentIndex].firstChar())))
 			{
 //				qDebug() << "rememberBreak implicitbreak @" << i-1;
 				current.rememberBreak(i - 1, breakPos);
-			}
+			}*/
 			current.isEmpty = (i - current.lineData.firstCluster + 1) == 0;
 
 			if (tabs.active)

ftake

2020-05-04 02:04

reporter   ~0047590

Thank you. This patch works for me.

Issue History

Date Modified Username Field Change
2020-04-28 09:41 ftake New Issue
2020-04-28 09:41 ftake File Added: no-line-break-after-CJK.png
2020-04-28 09:41 ftake File Added: no-line-break-after-CJK.sla
2020-04-29 13:46 jghali Note Added: 0047580
2020-04-29 13:53 jghali Note Added: 0047581
2020-04-30 15:09 ftake Note Added: 0047587
2020-05-01 19:50 jghali File Added: 16100_no_linebreak_between_cjk_and_latin_chars.patch
2020-05-01 19:50 jghali Note Added: 0047588
2020-05-03 21:36 jghali Assigned To => jghali
2020-05-03 21:36 jghali Status new => resolved
2020-05-03 21:36 jghali Resolution open => fixed
2020-05-03 21:36 jghali Fixed in Version => 1.5.6.svn
2020-05-04 02:04 ftake Note Added: 0047590
2020-08-11 20:56 cbradney Status resolved => closed