Page 1 of 2
Pango - Slowness
Posted: 2016-05-23T01:17:19-07:00
by rotem
Hello,
I'm using Pango to write arabic sentences over image but the problem that it is much slower than Label.
For example, each time I use label it takes 8 milliseconds and Pango takes 25 milliseconds.
Is there something to do about the speed?
BTW, I would rather use draw text than Pango or Label, so if you know any other way to write Arabic character with draw text it would be great.
Thank you
Re: Pango - Slowness
Posted: 2016-05-23T02:18:22-07:00
by snibgo
In my IM experiments with Arabic text, the only correct rendering is with Pango.
Re: Pango - Slowness
Posted: 2016-05-23T06:11:22-07:00
by rotem
oh, well do you know any way to scale up an image, or maybe create a vector?
What I'm looking to do is to create one image/vector with the Arabic sentence and then scale it up and down as I need to.
And one more thing is, how can I create stroke to text with Pango?
Thanks!
Re: Pango - Slowness
Posted: 2016-05-23T06:29:49-07:00
by snibgo
You can write the Arabic text into an SVG file, then render that. Inkscape works fine for that. IM can tell Inkscape to scale to whatever size you want.
Re: Pango - Slowness
Posted: 2016-05-23T06:40:13-07:00
by rotem
Ok, I can try that. Do you have an example for how to create svg file with pango?
What about the stroke, any ideas?
Re: Pango - Slowness
Posted: 2016-05-23T07:03:41-07:00
by snibgo
rotem wrote:Do you have an example for how to create svg file with pango?
No. But you can create one with a text editor. For example, paste this into a file called arabicSvg2.svg:
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="400px"
height="200px"
id="svg2"
version="1.1">
<g
id="layer1">
<text
xml:space="preserve"
style="fill:#000000;fill-opacity:1;stroke:none"
x="100"
y="100"
id="text2816"><tspan
id="tspan2818"
>šŋĩβģő élève äëïöü صَوْرة سِحْر</tspan></text>
</g>
</svg>
Here is a copy of that file:
http://snibgo.com/imforums/arabicSvg2.svg
Then run this command:
Code: Select all
convert -verbose -density 400 arabicSvg2.svg -trim +repage arabicSvg2.png
If your SVG delegate is Inkscape, the result will be something like this:
SVG with Inkscape is much slower than Pango.
I don't know what "create stroke to text" means.
Re: Pango - Slowness
Posted: 2016-05-23T07:20:34-07:00
by rotem
Thank you for the SVG example.
When I run the command you gave me I get:
Code: Select all
'inkscape' '/var/tmp/magick-57991dFioi5ZvgEps' --export-png='/var/tmp/magick-57991FCnP3PrpjFMj' --export-dpi='400,400' --export-background='rgb(0%,0%,0%)' --export-background-opacity='0' > '/var/tmp/magick-57991X06JGQLS2JSi' 2>&1
Fontconfig error: Cannot load default config file
Fontconfig error: Cannot load default config file
mvg:/var/tmp/magick-57991fbO4OlNaMKaq=>/var/tmp/magick-57991fbO4OlNaMKaq MVG 2222x1111 2222x1111+0+0 16-bit sRGB 337B 0.030u 0:00.029
1.svg MVG 2222x1111 2222x1111+0+0 16-bit sRGB 337B 0.010u 0:00.019
1.svg=>1.png MVG 2222x1111=>887x69 8-bit sRGB 11.3KB 0.010u 0:00.009
and this is the result image
am I doing something wrong?
(as for the stroke I mean the text stroke which can be added with the SVG)
--------------------------- UPDATE ------------------------------
I installed inkscape and now I get this message and an empty image
Code: Select all
'inkscape' '/var/tmp/magick-75838qR4kn1zwPs3J' --export-png='/var/tmp/magick-75838bSUH0TYvxEOD' --export-dpi='300,300' --export-background='rgb(100%,100%,100%)' --export-background-opacity='1' > '/var/tmp/magick-75838kkXJNVLcFAoy' 2>&1
/var/tmp/magick-75838bSUH0TYvxEOD PNG 1333x667 1333x667+0+0 8-bit sRGB 5.16KB 0.020u 0:00.019
1.svg SVG 1333x667 1333x667+0+0 8-bit sRGB 5.16KB 0.000u 0:00.009
1.svg=>1.png SVG 1333x667=>1x1 8-bit sRGB 2c 317B 0.000u 0:00.000
convert: geometry does not contain image `1.svg' @ warning/attribute.c/GetImageBoundingBox/247.
Re: Pango - Slowness
Posted: 2016-05-23T07:47:42-07:00
by snibgo
In your result, each character is written separately, and in the wrong order (left to right), so something is wrong.
Fontconfig error: Cannot load default config file
So the problem may be in "fontconfig".
Yes, Inkscape will do text strokes. It does most of SVG 1.1.
Re: Pango - Slowness
Posted: 2016-05-23T07:53:03-07:00
by rotem
Hey,
I managed to fix the fontconfig error but the output is still reversed...
What I couldn't figure out is how Pango and Inkscape are connected?
If I install Inkscape with `brew install inkscape` and now I get this message and an empty image file
Code: Select all
'inkscape' '/var/tmp/magick-75838qR4kn1zwPs3J' --export-png='/var/tmp/magick-75838bSUH0TYvxEOD' --export-dpi='300,300' --export-background='rgb(100%,100%,100%)' --export-background-opacity='1' > '/var/tmp/magick-75838kkXJNVLcFAoy' 2>&1
/var/tmp/magick-75838bSUH0TYvxEOD PNG 1333x667 1333x667+0+0 8-bit sRGB 5.16KB 0.020u 0:00.019
1.svg SVG 1333x667 1333x667+0+0 8-bit sRGB 5.16KB 0.000u 0:00.009
1.svg=>1.png SVG 1333x667=>1x1 8-bit sRGB 2c 317B 0.000u 0:00.000
convert: geometry does not contain image `1.svg' @ warning/attribute.c/GetImageBoundingBox/247.
if I remove the `-trim` I get an image with the right size but without any text inside it
Re: Pango - Slowness
Posted: 2016-05-23T08:20:21-07:00
by snibgo
Inkscape doesn't use Pango. Pango doesn't use Inkscape.
Try running Inkscape without IM. Can it read your SVG? Does it show correctly?
Re: Pango - Slowness
Posted: 2016-05-23T08:27:05-07:00
by rotem
I will try it in a sec.
Just one more question, can Inkscape with SVG create a good Arabic text like Pango make?
Re: Pango - Slowness
Posted: 2016-05-23T08:32:46-07:00
by snibgo
I don't know. It will depend on the font. Try it and see.
Re: Pango - Slowness
Posted: 2016-05-23T09:16:58-07:00
by rotem
Well, what font did you use to create the example you sent me?
Re: Pango - Slowness
Posted: 2016-05-23T09:21:40-07:00
by snibgo
I didn't specify a font, so Inkscape chose one. It might be Times New Roman.
Re: Pango - Slowness
Posted: 2016-05-23T13:30:06-07:00
by rotem
This is what I get when I run
Code: Select all
(process:78596): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
2016-05-23 23:28:34.329 inkscape[78596:5066113] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
Fontconfig error: Cannot load default config file
Fontconfig warning: ignoring UTF-8: not a valid region tag
Background RRGGBBAA: ffffff00
Area 0:0:400:200 exported to 400 x 200 pixels (90 dpi)
Bitmap saved as: 1.png
The file is in the right size but empty without any text.
What should I do?