View Issue Details

IDProjectCategoryView StatusLast Update
0015106ScribusStory Editor / Text Framespublic2019-12-08 21:24
ReporterFahad Assigned ToFahad  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Product Version1.5.4.svn 
Fixed in Version1.5.6.svn 
Summary0015106: First line indent doesn't support RTL text
Descriptionin styles editor when you modify indentation to set first line indent and you have RTL text frame, the new indentation will show as the text frame is LTR.

see the screenshot.
Tagspatch
PatchYes

Activities

Fahad

2018-01-17 14:01

developer  

first line.png (315,619 bytes)   
first line.png (315,619 bytes)   

Fahad

2019-10-05 19:13

developer   ~0046740

Hi, I 've developed a small patch to fix this. It is attached for your review.

Regards,
Fahad
firstLineIndentRTL (3,236 bytes)   
From b5795c96858872b72219f9b3e3897d97ee8e3c18 Mon Sep 17 00:00:00 2001
From: Fahad Al-Saidi <fahad.alsaidi@gmail.com>
Date: Sat, 5 Oct 2019 23:06:00 +0400
Subject: Support first line indent in RTL mode

The current logic for First Line Indent shifts shifts X form 0 to
X += style.firstIndent() which is the simple way to do it in LTR mode.
In RTL mode, we need to subtract firstIndent from current RTL's X starting
 point and line width should condsider RTL indent when it breaks the line.
Fix #246

diff --git a/scribus/pageitem_textframe.cpp b/scribus/pageitem_textframe.cpp
index 0db506cf6..e73233996 100644
--- a/scribus/pageitem_textframe.cpp
+++ b/scribus/pageitem_textframe.cpp
@@ -378,6 +378,7 @@ struct LineControl {
 	bool     addLeftIndent;
 	bool     wasFirstInRow;
 	double   leftIndent;
+	double   rightIndent;
 	double   rightMargin;
 	double   mustLineEnd;
 	int      restartIndex;  //index of glyph run where line computing should be restarted
@@ -419,6 +420,7 @@ struct LineControl {
 		addLeftIndent = false;
 		wasFirstInRow = false;
 		leftIndent = 0.0;
+		rightIndent = 0.0;
 		rightMargin = 0.0;
 		mustLineEnd = false;
 		restartIndex = 0;
@@ -478,6 +480,7 @@ struct LineControl {
 		maxShrink = 0.0;
 		maxStretch = 0.0;
 		leftIndent = 0.0;
+		rightIndent = 0.0;
 		rightMargin = 0.0;
 		rowDesc = 0.0;
 	}
@@ -1365,7 +1368,7 @@ void PageItem_TextFrame::layout()
 		ITextContext* context = this;
 		//TextShaper textShaper(this, itemText, firstInFrame());
 		ShapedTextFeed shapedText(&itemText, firstInFrame(), context);
-		
+
 		QList<GlyphCluster> glyphClusters; // = textShaper.shape();
 		// std::sort(glyphClusters.begin(), glyphClusters.end(), logicalGlyphRunComp);
 
@@ -1418,7 +1421,8 @@ void PageItem_TextFrame::layout()
 		current.lastInRowLine = false;
 		current.addLeftIndent = true;
 		current.wasFirstInRow = false;
-		current.leftIndent = 0;
+		current.leftIndent = 0.0;
+		current.rightIndent = 0.0;
 		current.rightMargin = 0.0;
 		current.mustLineEnd = current.colRight;
 		current.restartX = 0;
@@ -1797,7 +1801,16 @@ void PageItem_TextFrame::layout()
 					current.leftIndent = style.leftMargin() + autoLeftIndent;
 					if (itemText.isBlockStart(a))
 					{
-						current.leftIndent += style.firstIndent();
+						if (style.direction() == ParagraphStyle::RTL)
+						{
+							//use rightIndent to not miss with old behavior
+							current.rightIndent = style.firstIndent();
+							// line width should condsider RTL indent when it breaks the line.
+							current.mustLineEnd = current.colRight - style.firstIndent();
+
+						} else {
+							current.leftIndent += style.firstIndent();
+						}
 						if (BulNumMode || DropCmode)
 						{
 							if (style.parEffectIndent())
@@ -2552,7 +2565,7 @@ void PageItem_TextFrame::layout()
 						//current.updateLineOffset(itemText, style, firstLineOffset());
 						//current.xPos = current.breakXPos;
 						EndX = current.endOfLine(m_availableRegion, current.rightMargin, regionMinY, regionMaxY);
-						current.finishLine(EndX);
+						current.finishLine(EndX - current.rightIndent);
 
 						hyphWidth = 0.0;
 						if (current.glyphs[currentIndex].hasFlag(ScLayout_HyphenationPossible) || itemText.text(a) == SpecialChars::SHYPHEN)
firstLineIndentRTL (3,236 bytes)   

jghali

2019-10-07 00:10

administrator   ~0046747

Looks good. Applied! Thanks!

Issue History

Date Modified Username Field Change
2018-01-17 14:01 Fahad New Issue
2018-01-17 14:01 Fahad File Added: first line.png
2019-10-05 19:13 Fahad File Added: firstLineIndentRTL
2019-10-05 19:13 Fahad Note Added: 0046740
2019-10-06 15:16 ale Summary first line indent does't support RTL text => [PATCH] first line indent does't support RTL text
2019-10-06 15:16 ale Patch No => Yes
2019-10-06 15:19 ale Tag Attached: patch
2019-10-07 00:09 jghali Summary [PATCH] first line indent does't support RTL text => First line indent doesn't support RTL text
2019-10-07 00:10 jghali Note Added: 0046747
2019-10-07 00:17 jghali Assigned To => Fahad
2019-10-07 00:17 jghali Status new => resolved
2019-10-07 00:17 jghali Resolution open => fixed
2019-10-07 00:17 jghali Fixed in Version => 1.5.6.svn
2019-12-08 21:24 cbradney Status resolved => closed