pango and gravity ImageMagick 6.8.9-8

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
eldi
Posts: 7
Joined: 2014-12-19T15:15:05-07:00
Authentication code: 6789

pango and gravity ImageMagick 6.8.9-8

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: pango and gravity ImageMagick 6.8.9-8

Post 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.
eldi
Posts: 7
Joined: 2014-12-19T15:15:05-07:00
Authentication code: 6789

Re: pango and gravity ImageMagick 6.8.9-8

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: pango and gravity ImageMagick 6.8.9-8

Post 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
snibgo's IM pages: im.snibgo.com
eldi
Posts: 7
Joined: 2014-12-19T15:15:05-07:00
Authentication code: 6789

Re: pango and gravity ImageMagick 6.8.9-8

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: pango and gravity ImageMagick 6.8.9-8

Post 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.
snibgo's IM pages: im.snibgo.com
eldi
Posts: 7
Joined: 2014-12-19T15:15:05-07:00
Authentication code: 6789

Re: pango and gravity ImageMagick 6.8.9-8

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: pango and gravity ImageMagick 6.8.9-8

Post by fmw42 »

Perhaps this approach would work better for you. See http://www.imagemagick.org/Usage/text/#form_filling
eldi
Posts: 7
Joined: 2014-12-19T15:15:05-07:00
Authentication code: 6789

Re: pango and gravity ImageMagick 6.8.9-8

Post 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>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: pango and gravity ImageMagick 6.8.9-8

Post 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?
eldi
Posts: 7
Joined: 2014-12-19T15:15:05-07:00
Authentication code: 6789

Re: pango and gravity ImageMagick 6.8.9-8

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: pango and gravity ImageMagick 6.8.9-8

Post 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.
Post Reply