Page 1 of 1

pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-19T15:36:54-07:00
by eldi
Hi,

I'm not sure how gravity should work with PANGO, but I have seen examples with gravity center, I have tried it and it worked well, but when I applied west or east then text in spans with smaller fonts went to top. I have tried with SouthEast but that did not change anything. Could you tell me if I am doing something wrong or it is not possible with IM and PANGO? Funny thing is when you remove the -gravity East from command below, then it would render as expected :)


Code: Select all

convert -gravity East  -background none -define pango:wrap=word-char pango:"<u><span size=\"32528\" weight=\"bold\"><span size=\"9216\">This is</span>some text\n<span color=\"#FFFF00\">another</span></span></u>" t.png
p.s. there is another issue with this this command I would like to resolve, as the underline is generated for each different sized span, which does not look good. How can I add single underline for all text?

thanks for any help

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-19T15:48:01-07:00
by fmw42
According to https://developer.gnome.org/pango/stabl ... ormat.html, PANGO supports only south, east, north, west and auto gravity settings in the span. I do not know if there are conflicts with using IM -gravity and PANGO gravity settings.

Also see Anthony's notes about gravity center at http://www.imagemagick.org/Usage/text/#pango_markup

I am not an expert on PANGO, but have found some issues with gravity/justification. Perhaps one of the other users who are more knowledgeable can reply with better information.

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-19T16:07:26-07:00
by eldi
fmw42 wrote:According to https://developer.gnome.org/pango/stabl ... ormat.html, PANGO supports only south, east, north, west and auto gravity settings in the span. I do not know if there are conflicts with using IM -gravity and PANGO gravity settings.
Actually I have tried this PANGO gravity setting and it doesn't work.
fmw42 wrote: Also see Anthony's notes about gravity center at http://www.imagemagick.org/Usage/text/#pango_markup
Yes, I have seen that, and I used the gravity as he did:
I have not been able to get pango to selectively center just a single line of text. You can only center everything, or nothing via the "-gravity" setting.

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-19T20:54:44-07:00
by snibgo
Pango span gravity has a different meaning to IM's gravity setting.

My limited experiments with IM's gravity setting and Pango suggest that:
1. Pango ignores any north-south component.
2. "west" will right-justify text.
3. "east" will left justify text.

See http://im.snibgo.com/pango.htm

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-20T04:16:49-07:00
by eldi
So you are saying that it is not possible with PANGO and IM?

Could you propose any other tool to create image from text which would have basic manipulation of text as PANGO has?

p.s. your link doesn't work

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-20T05:03:43-07:00
by snibgo
eldi wrote:p.s. your link doesn't work
Oops, sorry, I hadn't published that page. It should work now.

The next step up from Pango is probably html2ps or htmltopdf. I have no experience with those.

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-20T06:44:14-07:00
by eldi
I think that it is worth adding my example to show what cannot be done with PANGO - I mean the align and correct underline when spans are in different sizes.

Nevertheless there is some issue with PANGO or implementation in IM, as I cannot understand why those two scenarios would not be handled.

I do not like like html2ps as I would have to generate img fom ps, and also need to handle the width, it looks like overhead to me. I like PANGO way as I can give the short string as: "test" and it will return correct img.

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-20T11:31:36-07:00
by fmw42
Perhaps this approach would work better for you. See http://www.imagemagick.org/Usage/text/#form_filling

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-20T12:27:29-07:00
by eldi
Thanks, but think that is good for static, mostly per line rendering, I cannot imagine what I would have to do to render this (I understand that every different font, font weight or color should be rendered as standalone image and then positioned on merged image appropriate?):
some bold and italic and underlined and color and with BIGGER text.

I like the PANGO for its markup language, where I can use as HTML (actually I am parsing html into PANGO markup and then render image):
<span font_family="Arial">Arial <span font_family="Serif">Serif</span></span>

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-20T12:32:41-07:00
by fmw42
OK. I don't think there is anything that IM can do to fix this. It is a Pango issue and IM relies upon the PANGO delegate to do the rendering. Have you tried using PANGO standalone to see if you have better control?

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-20T12:43:29-07:00
by eldi
No I haven't tried. I actually do not know where should I start, especially I remember C++ from my studies only, no mention C;-) Maybe do you know where I can find nice and easy tutorial for it?

Re: pango and gravity ImageMagick 6.8.9-8

Posted: 2014-12-20T13:26:10-07:00
by fmw42
I do not think you need either C or C++ to run Pango in the command line. I could be wrong. Sorry I do not know PANGO well enough to help.