[scribus] Scripter pica measure bug?

Juraj Fedel wtxnh-scribus at yahoo.com.au
Sun Aug 3 19:32:19 UTC 2014

On Sun, Aug 03, 2014 at 10:48:13AM +0200, Craig Bradney wrote:
> > There's no bug here. Picas are just points, displayed differently, so we changed to using a 1:1
> > ratio in unit conversion.
> > 
> Maybe Scripter needs a fix though.

In my copy of memoir manual
there is this table:

          Table 2: Printers units
Name (abbreviation)      Value
point (pt)
pica (pc)                1pc = 12pt
inch (in)                1in = 72.27pt
centimetre (cm)          2.54cm = 1in
millimetre (mm)          10mm = 1cm
big point (bp)           72bp = 72.27pt
didot point (dd)         1157dd = 1238pt
cicero (cc)              1cc = 12dd

According this table there are 12 points in 1 pica.
If I should be nitpicking what scribus names as 'point (pt)'
in the above table is denoted as 'big point (bp)'.
Maybe add 'didot point (dd)' for completeness.
Cicero is abbreviated as 'cc' instead of 'c'.
Also pica abbreviation here is 'pc' and in scribus it is 'p' or
empty string at some places - there is function:
const QString unitGetSuffixFromIndex(const int index)
        if (index==SC_P)
                return "";
        return QString(" %1").arg(unitGetStrFromIndex(index));

I will leave to more experienced people to decide how units names should
be used in scribus.

Asside of that in the function 
double unitValueFromString(const QString& value)
there is missing 'else if' construction for cicero.

Symbol for degree is not used consistently it this file.
There are three different representation of this symbol: '\xb0'
'\302\260' and '°'. As fourth case it is translated. 

Finally, as '%' and '°' are used in scripter as variable names and both
values are 1 I choose to not include them in scripter (you can not
access them anyway). Try to use command 'help(scribus)' in python script
to see what happens.

Also I think that variable names should be used as untranslated string
(or script that work in one locale can be broken under different locale

There is this line
      if (unitGetStrFromIndex(i) == "in")
and if "in" is translated it will not work as intended.
Here is my patch for that.


diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp
index 7d966a1..27d0b8a 100644
--- a/scribus/plugins/scriptplugin/scriptplugin.cpp
+++ b/scribus/plugins/scriptplugin/scriptplugin.cpp
@@ -731,7 +731,7 @@ void initscribus(ScribusMainWindow *pl)
 	// Measurement units understood by Scribus's units.cpp functions are exported as constant conversion
 	// factors to be used from Python.
-	for (int i = 0; i <= unitGetMaxIndex(); ++i)
+	for (int i = 0; i <= unitGetMaxIndex()-2; ++i)
 		PyObject* value = PyFloat_FromDouble(unitGetRatioFromIndex(i));
 		if (!value)
@@ -741,10 +741,10 @@ void initscribus(ScribusMainWindow *pl)
 		// `in' is a reserved word in Python so we must replace it
 		PyObject* name;
-		if (unitGetStrFromIndex(i) == "in")
+		if (unitGetUntranslatedStrFromIndex(i) == "in")
 			name = PyString_FromString("inch");
-			name = PyString_FromString(unitGetStrFromIndex(i).toLatin1().constData());
+			name = PyString_FromString(unitGetUntranslatedStrFromIndex(i).toLatin1().constData());
 		if (!name)
 			initscribus_failed(__FILE__, __LINE__);

More information about the scribus mailing list