View Issue Details

IDProjectCategoryView StatusLast Update
0009621ScribusTypographypublic2016-04-13 16:09
Reporteryoonminsoo Assigned Tojghali  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformPCOSWindowsOS VersionXP
Product Version1.3.9 
Fixed in Version1.5.0svn 
Summary0009621: Automatic linespacing does not work.
DescriptionAutomatic linespacing does not work.
In my sight, it is always 20%.
I try to set up <File-Preferences-Typography-Automatic line spacing> 1, 20, 50, 100%. But Always 20% is line spacing in my sight.
TagsNo tags attached.
Patch

Relationships

duplicate of 0004495 closedTsoots automatic linespacing mode broken? 
has duplicate 0012278 closedjghali Line height prefs cannot be set 
related to 0009742 closedfschmid Changing the line spacing percentage does not change the line spacing 

Activities

yoonminsoo

2010-12-26 06:54

reporter   ~0025203

And is it possible to set up autolinespacing percentage in paragraphes with different values?

cezaryece

2012-01-11 09:55

updater   ~0027513

Last edited: 2012-01-11 09:56

Here you have a patch fixing automatic line spacing issue.
Patch is against current 1.4.1 svn

cezaryece

2012-01-11 09:55

updater  

autoLineSpacing.patch (6,823 bytes)   
Index: Scribus/scribus/gtaction.cpp
===================================================================
--- Scribus/scribus/gtaction.cpp	(wersja 17188)
+++ Scribus/scribus/gtaction.cpp	(kopia robocza)
@@ -606,7 +606,7 @@
 
 double gtAction::getLineSpacing(int fontSize)
 {
-	return ((fontSize / 10.0) * static_cast<double>(textFrame->doc()->typographicSettings.autoLineSpacing) / 100) + (fontSize / 10.0);
+	return ((fontSize / 10.0) * (1 + static_cast<double>(textFrame->doc()->typographicSettings.autoLineSpacing) / 100.0));
 }
 
 double gtAction::getFrameWidth()
Index: Scribus/scribus/scpageoutput.cpp
===================================================================
--- Scribus/scribus/scpageoutput.cpp	(wersja 17188)
+++ Scribus/scribus/scpageoutput.cpp	(kopia robocza)
@@ -1362,6 +1362,10 @@
 			painter->scale(1, -1);
 		}
 		uint tabCc = 0;
+
+		//automatic line spacing factor (calculated once)
+		double autoLS = 1 + static_cast<double>(m_doc->typographicSettings.autoLineSpacing) / 100.0;
+
 		for (uint ll=0; ll < item->itemText.lines(); ++ll)
 		{
 			LineSpec ls = item->itemText.line(ll);
@@ -1395,8 +1399,8 @@
 						if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
 							chs = qRound(10 * ((style.lineSpacing() * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
 						else
-						{
-							double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0);
+						{ //ParagraphStyle::AutomaticLineSpacing
+							double currasce = charStyle.font().height(style.charStyle().fontSize() * autoLS / 10.0);
 							chs = qRound(10 * ((currasce * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
 						}
 					}
Index: Scribus/scribus/pageitem_textframe.cpp
===================================================================
--- Scribus/scribus/pageitem_textframe.cpp	(wersja 17188)
+++ Scribus/scribus/pageitem_textframe.cpp	(kopia robocza)
@@ -1087,6 +1087,9 @@
 		current.nextColumn();
 		lastLineY = extra.Top;
 
+		//automatic line spacing factor (calculated once)
+		double autoLS = 1 + static_cast<double>(m_Doc->typographicSettings.autoLineSpacing) / 100.0;
+
 		// find start of first line
 		if (firstInFrame() < itemText.length())
 		{
@@ -1094,7 +1097,7 @@
 			style = itemText.paragraphStyle(firstInFrame());
 			if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
 			{
-				style.setLineSpacing(style.charStyle().font().height(style.charStyle().fontSize() / 10.0));
+				style.setLineSpacing(style.charStyle().font().height(style.charStyle().fontSize() * autoLS / 10.0));
 //				qDebug() << QString("auto linespacing: %1").arg(style.lineSpacing());
 			}
 			else if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
@@ -1156,9 +1159,10 @@
 			if (chstr.isEmpty())
 				chstr = SpecialChars::ZWNBSPACE;
 			if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
-				style.setLineSpacing(charStyle.font().height(hlcsize10));
+				style.setLineSpacing((charStyle.fontSize() /10) * autoLS);
 			else if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
 				style.setLineSpacing(m_Doc->typographicSettings.valueBaseGrid);
+			double LS = style.lineSpacing();
 			// find out about par gap and dropcap
 			if (a == firstInFrame())
 			{
@@ -2057,8 +2061,9 @@
 					{
 						// go back to last break position
 						style = itemText.paragraphStyle(a);
+						double size = style.charStyle().fontSize() / 10;
 						if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
-							style.setLineSpacing(charStyle.font().height(hlcsize10));
+							style.setLineSpacing(size * autoLS);
 						else if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
 							style.setLineSpacing(m_Doc->typographicSettings.valueBaseGrid);
 						
Index: Scribus/scribus/scribusdoc.cpp
===================================================================
--- Scribus/scribus/scribusdoc.cpp	(wersja 17188)
+++ Scribus/scribus/scribusdoc.cpp	(kopia robocza)
@@ -6096,11 +6096,11 @@
 	{
 		ParagraphStyle storyStyle;
 		storyStyle.charStyle().setFontSize(size);
-		if (storyStyle.lineSpacingMode() == 0)
+		if (storyStyle.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
 		{
-			storyStyle.setLineSpacing(((size / 10.0) * static_cast<double>(typographicSettings.autoLineSpacing) / 100) + (size / 10.0));
+			storyStyle.setLineSpacing((size / 10.0) * (1 + static_cast<double>(typographicSettings.autoLineSpacing) / 100.0));
 		}
-		else if (storyStyle.lineSpacingMode() == 1)
+		else if (storyStyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
 		{
 			storyStyle.setLineSpacing(storyStyle.charStyle().font().height(size));
 		}
Index: Scribus/scribus/sampleitem.cpp
===================================================================
--- Scribus/scribus/sampleitem.cpp	(wersja 17188)
+++ Scribus/scribus/sampleitem.cpp	(kopia robocza)
@@ -57,9 +57,7 @@
 	bgShade = 100;
 	tmpStyle.setName("(preview temporary)");
 	tmpStyle.setLineSpacingMode(ParagraphStyle::FixedLineSpacing);
-	tmpStyle.setLineSpacing((m_Doc->toolSettings.defSize / 10.0)
-		* static_cast<double>(m_Doc->typographicSettings.autoLineSpacing) / 100
-		+ (m_Doc->toolSettings.defSize / 10.0));
+	tmpStyle.setLineSpacing((m_Doc->toolSettings.defSize / 10.0) * (1 + static_cast<double>(m_Doc->typographicSettings.autoLineSpacing) / 100.0));
 	tmpStyle.setAlignment(ParagraphStyle::Leftaligned);
 	tmpStyle.setLeftMargin(0);
 	tmpStyle.setFirstIndent(0);
@@ -196,7 +194,7 @@
 {
 	tmpStyle.charStyle().setFontSize(fontSize);
 	if (autoLineSpa)
-		tmpStyle.setLineSpacing(((fontSize / 10)  * (m_Doc->typographicSettings.autoLineSpacing / 100) + (fontSize / 10)));
+		tmpStyle.setLineSpacing((fontSize / 10)  * (1 + static_cast<double>(m_Doc->typographicSettings.autoLineSpacing) / 100.0));
 }
 
 /*void SampleItem::setTabValues(QValueList<PageItem::TabRecord> tabValues)
Index: Scribus/scribus/tabtypography.cpp
===================================================================
--- Scribus/scribus/tabtypography.cpp	(wersja 17188)
+++ Scribus/scribus/tabtypography.cpp	(kopia robocza)
@@ -137,8 +137,11 @@
 	groupBox4aLayout->setSpacing(5);
 	groupBox4aLayout->setAlignment( Qt::AlignTop );
 	autoLine = new QSpinBox( groupBox4a );
-	autoLine->setMaximum( 100 );
-	autoLine->setMinimum( 1 );
+	// autoLine->setMaximum( 100 );
+	// autoLine->setMinimum( 1 );
+	// FIX ME: why not these values?
+	autoLine->setMaximum( 999 );
+	autoLine->setMinimum( 0 );
 	autoLine->setSuffix( tr( " %" ) );
 	groupBox4aLayout->addWidget( autoLine, 1, 1, Qt::AlignLeft );
 	textLabel8a = new QLabel( tr( "Line Spacing:" ), groupBox4a );
 
autoLineSpacing.patch (6,823 bytes)   

cezaryece

2012-01-13 08:33

updater   ~0027540

I use variable "autoLS" calculated once at text layout start.
Changing it to value for frame or paragraph style will be quite simply.

jghali

2012-01-22 01:52

administrator  

9621_autoLineSpacing_trunk.patch (20,808 bytes)   
Index: scribus/CMakeLists.txt
===================================================================
--- scribus/CMakeLists.txt	(revision 17213)
+++ scribus/CMakeLists.txt	(working copy)
@@ -588,6 +588,7 @@
   sccolorshade.cpp
   scdocoutput.cpp
   scdocoutput_ps2.cpp
+  scdomelement.cpp
   scfonts.cpp
   scgtplugin.cpp
   scgzfile.cpp
Index: scribus/gtaction.cpp
===================================================================
--- scribus/gtaction.cpp	(revision 17213)
+++ scribus/gtaction.cpp	(working copy)
@@ -616,7 +616,7 @@
 
 double gtAction::getLineSpacing(int fontSize)
 {
-	return ((fontSize / 10.0) * static_cast<double>(textFrame->doc()->typographicPrefs().autoLineSpacing) / 100) + (fontSize / 10.0);
+	return ((fontSize / 10.0) * (static_cast<double>(textFrame->doc()->typographicPrefs().autoLineSpacing) / 100));
 }
 
 double gtAction::getFrameWidth()
Index: scribus/pageitem_textframe.cpp
===================================================================
--- scribus/pageitem_textframe.cpp	(revision 17215)
+++ scribus/pageitem_textframe.cpp	(working copy)
@@ -1131,7 +1131,10 @@
 static double calculateLineSpacing (const ParagraphStyle &style, PageItem *item)
 {
 	if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
-		return style.charStyle().font().height(style.charStyle().fontSize() / 10.0);
+	{
+		double autoLS = static_cast<double>(item->doc()->typographicPrefs().autoLineSpacing) / 100.0;
+		return (style.charStyle().font().height(style.charStyle().fontSize() / 10.0) * autoLS);
+	}
 	if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
 		return item->doc()->guidesPrefs().valueBaselineGrid;
 	return style.lineSpacing();
@@ -1347,6 +1350,9 @@
 		current.nextColumn();
 		lastLineY = extra.Top;
 
+		//automatic line spacing factor (calculated once)
+		double autoLS = static_cast<double>(m_Doc->typographicPrefs().autoLineSpacing) / 100.0;
+
 		// find start of first line
 		if (firstInFrame() < itemText.length())
 		{
@@ -2313,7 +2319,7 @@
 						// go back to last break position
 						style = itemText.paragraphStyle(a);
 						if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
-							style.setLineSpacing(charStyle.font().height(hlcsize10));
+							style.setLineSpacing(charStyle.font().height(hlcsize10) * autoLS);
 						else if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
 							style.setLineSpacing(m_Doc->guidesPrefs().valueBaselineGrid);
 						
Index: scribus/plugins/fileloader/scribus12format/scribus12format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus12format/scribus12format.cpp	(revision 17213)
+++ scribus/plugins/fileloader/scribus12format/scribus12format.cpp	(working copy)
@@ -836,7 +836,8 @@
 		m_Doc->typographicPrefs().valueSmallCaps = dc.attribute("VKAPIT").toInt();
 		m_Doc->guidesPrefs().valueBaselineGrid = ScCLocale::toDoubleC(dc.attribute("BASEGRID"), 12.0);
 		m_Doc->guidesPrefs().offsetBaselineGrid = ScCLocale::toDoubleC(dc.attribute("BASEO"), 0.0);
-		m_Doc->typographicPrefs().autoLineSpacing = dc.attribute("AUTOL", "20").toInt();
+		// #9621 : autolinespacing is now express as a percentage of the font height
+		m_Doc->typographicPrefs().autoLineSpacing = 100 /*dc.attribute("AUTOL", "20").toInt()*/;
 		m_Doc->GroupCounter = 1 /*dc.attribute("GROUPC", "1").toInt()*/;
 		//m_Doc->HasCMS = static_cast<bool>(dc.attribute("HCMS", "0").toInt());
 		m_Doc->cmsSettings().SoftProofOn = static_cast<bool>(dc.attribute("DPSo", "0").toInt());
Index: scribus/plugins/fileloader/scribus134format/scribus134format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(revision 17213)
+++ scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(working copy)
@@ -1029,7 +1029,9 @@
 	doc->typographicPrefs().valueSmallCaps     = attrs.valueAsInt("VKAPIT");
 	doc->guidesPrefs().valueBaselineGrid      = attrs.valueAsDouble("BASEGRID", 12.0);
 	doc->guidesPrefs().offsetBaselineGrid     = attrs.valueAsDouble("BASEO", 0.0);
-	doc->typographicPrefs().autoLineSpacing    = attrs.valueAsInt("AUTOL", 20);
+	// #9621 : autolinespacing is now express as a percentage of the font height
+	// It was not working in regualer text frame in 1.3.4+, so set it to the default value
+	doc->typographicPrefs().autoLineSpacing    = 100 /*attrs.valueAsInt("AUTOL", 20)*/;
 	doc->typographicPrefs().valueUnderlinePos  = attrs.valueAsInt("UnderlinePos", -1);
 	doc->typographicPrefs().valueUnderlineWidth  = attrs.valueAsInt("UnderlineWidth", -1);
 	doc->typographicPrefs().valueStrikeThruPos   = attrs.valueAsInt("StrikeThruPos", -1);
Index: scribus/plugins/fileloader/scribus13format/scribus13format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus13format/scribus13format.cpp	(revision 17213)
+++ scribus/plugins/fileloader/scribus13format/scribus13format.cpp	(working copy)
@@ -296,7 +296,9 @@
 		m_Doc->typographicPrefs().valueSmallCaps = dc.attribute("VKAPIT").toInt();
 		m_Doc->guidesPrefs().valueBaselineGrid  = ScCLocale::toDoubleC(dc.attribute("BASEGRID"), 12.0);
 		m_Doc->guidesPrefs().offsetBaselineGrid = ScCLocale::toDoubleC(dc.attribute("BASEO"), 0.0);
-		m_Doc->typographicPrefs().autoLineSpacing = dc.attribute("AUTOL", "20").toInt();
+		// #9621 : autolinespacing is now express as a percentage of the font height
+		// It was not working in regualer text frame in 1.3.x, so set it to the default value
+		m_Doc->typographicPrefs().autoLineSpacing = 100 /*dc.attribute("AUTOL", "20").toInt()*/;
 		m_Doc->typographicPrefs().valueUnderlinePos = dc.attribute("UnderlinePos", "-1").toInt();
 		m_Doc->typographicPrefs().valueUnderlineWidth = dc.attribute("UnderlineWidth", "-1").toInt();
 		m_Doc->typographicPrefs().valueStrikeThruPos = dc.attribute("StrikeThruPos", "-1").toInt();
Index: scribus/plugins/fileloader/scribus150format/scribus150format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(revision 17213)
+++ scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(working copy)
@@ -2085,7 +2085,8 @@
 	doc->typographicPrefs().valueSmallCaps     = attrs.valueAsInt("VKAPIT");
 	doc->guidesPrefs().valueBaselineGrid      = attrs.valueAsDouble("BASEGRID", 12.0);
 	doc->guidesPrefs().offsetBaselineGrid     = attrs.valueAsDouble("BASEO", 0.0);
-	doc->typographicPrefs().autoLineSpacing    = attrs.valueAsInt("AUTOL", 20);
+	// #9621 : autolinespacing is now expressed as a percentage of the font height
+	doc->typographicPrefs().autoLineSpacing    = attrs.valueAsInt("AUTOL", 100, 200, 100);
 	doc->typographicPrefs().valueUnderlinePos  = attrs.valueAsInt("UnderlinePos", -1);
 	doc->typographicPrefs().valueUnderlineWidth  = attrs.valueAsInt("UnderlineWidth", -1);
 	doc->typographicPrefs().valueStrikeThruPos   = attrs.valueAsInt("StrikeThruPos", -1);
Index: scribus/prefsmanager.cpp
===================================================================
--- scribus/prefsmanager.cpp	(revision 17213)
+++ scribus/prefsmanager.cpp	(working copy)
@@ -37,25 +37,27 @@
 #include "commonstrings.h"
 #include "filewatcher.h"
 #include "latexhelpers.h"
-#include "ui/missing.h"
-#include "ui/prefs_keyboardshortcuts.h"
 #include "pagesize.h"
 #include "pagestructs.h"
 #include "pdfoptions.h"
 #include "prefsfile.h"
 #include "scclocale.h"
 #include "sccolorengine.h"
+#include "scdomelement.h"
 #include "scfonts.h"
-#include "ui/scmessagebox.h"
 #include "scpaths.h"
 #include "scribuscore.h"
 #include "scribusstructs.h"
 #include "sctextstream.h"
-#include "ui/modetoolbar.h"
 #include "util_color.h"
 #include "util_file.h"
 #include "util_ghostscript.h"
 
+#include "ui/missing.h"
+#include "ui/modetoolbar.h"
+#include "ui/prefs_keyboardshortcuts.h"
+#include "ui/scmessagebox.h"
+
 extern bool emergencyActivated;
 
 PrefsManager* PrefsManager::_instance = 0;
@@ -189,7 +191,7 @@
 	appPrefs.typoPrefs.valueSubScript = 33;
 	appPrefs.typoPrefs.scalingSubScript = 66;
 	appPrefs.typoPrefs.valueSmallCaps = 75;
-	appPrefs.typoPrefs.autoLineSpacing = 20;
+	appPrefs.typoPrefs.autoLineSpacing = 100;
 	appPrefs.typoPrefs.valueUnderlinePos = -1;
 	appPrefs.typoPrefs.valueUnderlineWidth = -1;
 	appPrefs.typoPrefs.valueStrikeThruPos = -1;
@@ -1861,7 +1863,7 @@
 		return false;
 	}
 	f.close();
-	QDomElement elem=docu.documentElement();
+	ScDomElement elem = docu.documentElement();
 	if (elem.tagName() != "SCRIBUSRC")
 		return false;
 	//Ignore scribus*.rc files prior to 1.5.0 due to changes
@@ -1886,7 +1888,7 @@
 		appPrefs.verifierPrefs.checkerPrefsList.clear();
 	while(!DOC.isNull())
 	{
-		QDomElement dc=DOC.toElement();
+		ScDomElement dc = DOC.toElement();
 
 		if (dc.tagName()=="UI")
 		{
@@ -2036,7 +2038,7 @@
 			appPrefs.typoPrefs.valueSubScript = dc.attribute("SubScriptDistance").toInt();
 			appPrefs.typoPrefs.scalingSubScript = dc.attribute("SubScriptScaling").toInt();
 			appPrefs.typoPrefs.valueSmallCaps  = dc.attribute("SmallCapsScaling").toInt();
-			appPrefs.typoPrefs.autoLineSpacing = dc.attribute("AutomaticLineSpacing", "20").toInt();
+			appPrefs.typoPrefs.autoLineSpacing = dc.valueAsUInt("AutomaticLineSpacing", 100, 200, 100);
 			double ulp = ScCLocale::toDoubleC(dc.attribute("UnderlineDistance"), -1.0);
 			if (ulp != -1)
 				appPrefs.typoPrefs.valueUnderlinePos = qRound(ulp * 10);
@@ -2202,7 +2204,7 @@
 			while(!scrp.isNull())
 			{
 				QDomElement scrpElem = scrp.toElement();
-				if (scrpElem.tagName()=="Recent")
+				if (scrpElem.tagName() == "Recent")
 				{
 					QString nam = scrpElem.attribute("Name");
 					QFileInfo fd(nam);
Index: scribus/sampleitem.cpp
===================================================================
--- scribus/sampleitem.cpp	(revision 17213)
+++ scribus/sampleitem.cpp	(working copy)
@@ -36,9 +36,7 @@
 	bgShade = 100;
 	tmpStyle.setName("(preview temporary)");
 	tmpStyle.setLineSpacingMode(ParagraphStyle::FixedLineSpacing);
-	tmpStyle.setLineSpacing((m_Doc->itemToolPrefs().textSize / 10.0)
-		* static_cast<double>(m_Doc->typographicPrefs().autoLineSpacing) / 100
-		+ (m_Doc->itemToolPrefs().textSize / 10.0));
+	tmpStyle.setLineSpacing((m_Doc->itemToolPrefs().textSize / 10.0) * (static_cast<double>(m_Doc->typographicPrefs().autoLineSpacing) / 100));
 	tmpStyle.setAlignment(ParagraphStyle::Leftaligned);
 	tmpStyle.setLeftMargin(0);
 	tmpStyle.setFirstIndent(0);
@@ -162,7 +160,7 @@
 {
 	tmpStyle.charStyle().setFontSize(fontSize);
 	if (autoLineSpa)
-		tmpStyle.setLineSpacing(((fontSize / 10)  * (m_Doc->typographicPrefs().autoLineSpacing / 100) + (fontSize / 10)));
+		tmpStyle.setLineSpacing((fontSize / 10)  * (m_Doc->typographicPrefs().autoLineSpacing / 100.0));
 }
 
 /*void SampleItem::setTabValues(QValueList<PageItem::TabRecord> tabValues)
Index: scribus/scdomelement.cpp
===================================================================
--- scribus/scdomelement.cpp	(revision 0)
+++ scribus/scdomelement.cpp	(revision 0)
@@ -0,0 +1,74 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+
+#include "scclocale.h"
+#include "scdomelement.h"
+
+ScDomElement::ScDomElement() : QDomElement()
+{
+
+}
+
+ScDomElement::ScDomElement(const QDomElement &elem) : QDomElement(elem)
+{
+
+}
+
+int ScDomElement::valueAsInt (const QString& attrName, int def) const
+{
+	int retValue = def;
+	QString attr = attribute(attrName);
+	if (!attr.isEmpty())
+	{
+		bool success = false;
+		int intVal = attr.toInt(&success);
+		if (success)
+			retValue = intVal;
+	}
+	return retValue;
+}
+
+int ScDomElement::valueAsInt (const QString& attrName, int min, int max, int def) const
+{
+	int value = valueAsInt(attrName, def);
+	return qMin(max, qMax(value, min));
+}
+
+uint ScDomElement::valueAsUInt (const QString& attrName, uint def) const
+{
+	uint retValue = def;
+	QString attr = attribute(attrName);
+	if (!attr.isEmpty())
+	{
+		bool success = false;
+		uint intVal = attr.toUInt(&success);
+		if (success)
+			retValue = intVal;
+	}
+	return retValue;
+}
+
+uint ScDomElement::valueAsUInt (const QString& attrName, uint min, uint max, uint def) const
+{
+	uint value = valueAsUInt(attrName, def);
+	return qMin(max, qMax(value, min));
+}
+
+double ScDomElement::valueAsDouble (const QString& attrName, double def) const
+{
+	double retValue = def;
+	QString attr = attribute(attrName);
+	if (!attr.isEmpty())
+		retValue = ScCLocale::toDoubleC(attr, def);
+	return retValue;
+}
+
+double ScDomElement::valueAsDouble (const QString& attrName, double min, double max, double def) const
+{
+	double value = valueAsDouble(attrName, def);
+	return qMin(max, qMax(value, min));
+}
Index: scribus/scdomelement.h
===================================================================
--- scribus/scdomelement.h	(revision 0)
+++ scribus/scdomelement.h	(revision 0)
@@ -0,0 +1,26 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+#ifndef SCDOMELEMENT_H
+#define SCDOMELEMENT_H
+
+#include <QDomElement>
+
+class ScDomElement : public QDomElement
+{
+public:
+	ScDomElement();
+	ScDomElement(const QDomElement &elem); 
+
+	int     valueAsInt    (const QString& attrName, int def = 0) const;
+	int     valueAsInt    (const QString& attrName, int min, int max, int def = 0) const;
+	uint    valueAsUInt   (const QString& attrName, uint def = 0) const;
+	uint    valueAsUInt   (const QString& attrName, uint min, uint max, uint def = 0) const;
+	double  valueAsDouble (const QString& attrName, double def = 0.0) const;
+	double  valueAsDouble (const QString& attrName, double min, double max, double def = 0.0) const;
+};
+
+#endif
Index: scribus/scpageoutput.cpp
===================================================================
--- scribus/scpageoutput.cpp	(revision 17213)
+++ scribus/scpageoutput.cpp	(working copy)
@@ -1234,6 +1234,10 @@
 			painter->scale(1, -1);
 		}
 		uint tabCc = 0;
+
+		//automatic line spacing factor (calculated once)
+		double autoLS = static_cast<double>(m_doc->typographicPrefs().autoLineSpacing) / 100.0;
+
 		for (uint ll=0; ll < item->itemText.lines(); ++ll)
 		{
 			LineSpec ls = item->itemText.line(ll);
@@ -1261,15 +1265,12 @@
 					const ParagraphStyle& style(item->itemText.paragraphStyle(a));
 					if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
 						chs = qRound(10 * ((m_doc->guidesPrefs().valueBaselineGrid * (style.dropCapLines()-1) + (charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
+					else if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
+						chs = qRound(10 * ((style.lineSpacing() * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
 					else
 					{
-						if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
-							chs = qRound(10 * ((style.lineSpacing() * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
-						else
-						{
-							double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0);
-							chs = qRound(10 * ((currasce * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
-						}
+						double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0) * autoLS;
+						chs = qRound(10 * ((currasce * (style.dropCapLines() - 1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
 					}
 				}
 				if (chstr[0] == SpecialChars::TAB)
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 17213)
+++ scribus/scribusdoc.cpp	(working copy)
@@ -7836,11 +7836,11 @@
 	{
 		ParagraphStyle storyStyle;
 		storyStyle.charStyle().setFontSize(size);
-		if (storyStyle.lineSpacingMode() == 0)
+		if (storyStyle.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
 		{
-			storyStyle.setLineSpacing(((size / 10.0) * static_cast<double>(docPrefsData.typoPrefs.autoLineSpacing) / 100) + (size / 10.0));
+			storyStyle.setLineSpacing((size / 10.0) * (static_cast<double>(docPrefsData.typoPrefs.autoLineSpacing) / 100));
 		}
-		else if (storyStyle.lineSpacingMode() == 1)
+		else if (storyStyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
 		{
 			storyStyle.setLineSpacing(storyStyle.charStyle().font().height(size));
 		}
@@ -13066,7 +13066,7 @@
 //			bb->setFontSize(qMax(qRound(bb->fontSize()*((scx+scy)/2)), 1));
 			if ((bb->itemText.length() != 0) && (!bb->isTableItem))
 			{
-//				bb->setLineSpacing(((bb->fontSize() / 10.0) * static_cast<double>(Doc->typographicSettings.autoLineSpacing) / 100) + (bb->fontSize() / 10.0));
+//				bb->setLineSpacing(((bb->fontSize() / 10.0) * static_cast<double>(Doc->typographicSettings.autoLineSpacing) / 100));
 				for (aa = 0; aa < bb->itemText.length(); ++aa)
 					bb->itemText.item(aa)->setFontSize(qMax(qRound(bb->itemText.item(aa)->fontSize()*((scx+scy)/2)), 1));
 				if (bb->asPathText())
Index: scribus/scxmlstreamreader.cpp
===================================================================
--- scribus/scxmlstreamreader.cpp	(revision 17213)
+++ scribus/scxmlstreamreader.cpp	(working copy)
@@ -80,6 +80,18 @@
 	return retValue;
 }
 
+int ScXmlStreamAttributes::valueAsInt (const char* attrName, int min, int max, int def) const
+{
+	int value = valueAsInt(attrName, def);
+	return qMin(max, qMax(value, min));
+}
+
+int ScXmlStreamAttributes::valueAsInt (const QString& attrName, int min, int max, int def) const
+{
+	int value = valueAsInt(attrName, def);
+	return qMin(max, qMax(value, min));
+}
+
 uint ScXmlStreamAttributes::valueAsUInt  (const char*    attrName, uint def) const
 {
 	uint retValue = def;
Index: scribus/scxmlstreamreader.h
===================================================================
--- scribus/scxmlstreamreader.h	(revision 17213)
+++ scribus/scxmlstreamreader.h	(working copy)
@@ -23,6 +23,8 @@
 	bool    valueAsBool   (const QString& attrName, bool def = false) const;
 	int     valueAsInt    (const char*    attrName, int def = 0) const;
 	int     valueAsInt    (const QString& attrName, int def = 0) const;
+	int     valueAsInt    (const char*    attrName, int min, int max, int def = 0) const;
+	int     valueAsInt    (const QString& attrName, int min, int max, int def = 0) const;
 	uint    valueAsUInt   (const char*    attrName, uint def = 0) const;
 	uint    valueAsUInt   (const QString& attrName, uint def = 0) const;
 	double  valueAsDouble (const char*    attrName, double def = 0.0) const;
Index: scribus/styles/paragraphstyle.cpp
===================================================================
--- scribus/styles/paragraphstyle.cpp	(revision 17213)
+++ scribus/styles/paragraphstyle.cpp	(working copy)
@@ -98,7 +98,7 @@
 	switch (that.lineSpacingMode())
 	{
 		case 0: 
-			that.setLineSpacing(((that.charStyle().fontSize() / 10.0) * static_cast<qreal>(typographicSettings.autoLineSpacing) / 100) + (size / 10.0));
+			that.setLineSpacing(((that.charStyle().fontSize() / 10.0) * static_cast<qreal>(typographicSettings.autoLineSpacing) / 100));
 			break;
 		case 1:
 			that.setLineSpacing(that.charStyle().font().height(size));
Index: scribus/ui/prefs_typographybase.ui
===================================================================
--- scribus/ui/prefs_typographybase.ui	(revision 17213)
+++ scribus/ui/prefs_typographybase.ui	(working copy)
@@ -515,9 +515,12 @@
            <property name="suffix">
             <string> %</string>
            </property>
-           <property name="maximum">
+           <property name="minimum">
             <number>100</number>
            </property>
+           <property name="maximum">
+            <number>200</number>
+           </property>
           </widget>
          </item>
         </layout>

jghali

2012-01-22 01:59

administrator   ~0027585

Last edited: 2012-01-22 02:01

As that patch would affect text layout quite importantly, it will not be committed to trunk. I consequently ported it to trunk. However i had to make some changes in order to keep a good compatibility with older documents. Noticeably i had to change the meaning of the automatic linespacing value, as set in prefs, to a percentage of the font height. I've set its default value to 100%. The former value was simply not taken into account while layouting text frames, the default value will allow to preserve layout of the older docs.

I've uploaded the patch if anyone want to test it a bit, gonna commit it probably tomorrow.

fschmid

2012-01-22 07:15

developer   ~0027586

Keeping the auto linespacing as a percentage of the font height is a good idea, Indesign does it the same way.

fschmid

2012-01-22 07:19

developer   ~0027587

For the spinbox control i suggest a range from 1% to 500%, same as described in Indesign's IDML specs.

jghali

2012-01-22 18:59

administrator   ~0027588

I modified the maximum value for the spinbox to 500%. However i had to leave the minimum value to 100% as using values below 100% does not seem to work currently. I also added some check to document prefs code so that a change to typographic settings triggers an update of text layout.

cezaryece

2012-01-26 14:38

updater   ~0027599

Starting from 100% sound good, but IMO default value should be 120%, so for 10 pt font line spacing should be 12 pt - it is standard in DTP.

Issue History

Date Modified Username Field Change
2010-12-26 06:51 yoonminsoo New Issue
2010-12-26 06:54 yoonminsoo Note Added: 0025203
2012-01-11 09:55 cezaryece Note Added: 0027513
2012-01-11 09:55 cezaryece File Added: autoLineSpacing.patch
2012-01-11 09:56 cezaryece Note Edited: 0027513
2012-01-13 08:33 cezaryece Note Added: 0027540
2012-01-22 01:52 jghali File Added: 9621_autoLineSpacing_trunk.patch
2012-01-22 01:59 jghali Note Added: 0027585
2012-01-22 02:01 jghali Note Edited: 0027585
2012-01-22 07:15 fschmid Note Added: 0027586
2012-01-22 07:19 fschmid Note Added: 0027587
2012-01-22 18:59 jghali Note Added: 0027588
2012-01-22 18:59 jghali Status new => resolved
2012-01-22 18:59 jghali Fixed in Version => 1.5.0svn
2012-01-22 18:59 jghali Resolution open => fixed
2012-01-22 18:59 jghali Assigned To => jghali
2012-01-26 14:38 cezaryece Note Added: 0027599
2012-04-29 10:59 cbradney Status resolved => closed
2012-09-02 17:34 ale Relationship added duplicate of 0004495
2014-04-24 19:52 jghali Relationship added has duplicate 0012278
2016-04-13 16:09 Kunda Relationship added related to 0009742