Page 1 of 1

possible bug with pango: and & or & in text string

Posted: 2017-04-06T14:46:15-07:00
by fmw42
see viewtopic.php?f=1&t=31723&p=144873#p144873

This fails:

Code: Select all

convert -size 100x100 -font arial -gravity center pango:"&åß∂ƒ©" tmp.png
as does

Code: Select all

convert -size 100x100 -font arial -gravity center pango:"&åß∂ƒ©" tmp.png

Re: possible bug with pango: and & or & in text string

Posted: 2017-04-06T14:55:18-07:00
by fmw42
Here is a workaround. Escape the ; as \;

Code: Select all

convert -size 100x100 -font arial -gravity center pango:"&amp\;åß∂ƒ©" tmp.png
It seems to work for me.

Re: possible bug with pango: and & or & in text string

Posted: 2017-04-07T00:55:54-07:00
by snibgo
Other workarounds:

1. Prefix with backslash, eg

Code: Select all

convert -size 100x100 -font arial -gravity center pango:"hello \& world" t.png
Yes, this works on Windows, where backslash isn't the escape.

2. Put the pango string in a file, at @ it, eg put

Code: Select all

Hello & world
... into pangoamp.txt, then:

Code: Select all

convert -size 100x100 -font arial -gravity center pango:@pangoamp.txt t.png

This is the problem cause:

pango.c function ReadPANGOImage() takes the string after "pango:", which is a kind-of filename.

It parses that string with property.c InterpretImageProperties(). This translates "\n" into newline, and other translations, including "&" to "&".

So a string with "&" will passed to pango with a naked "&".

That's the problem. I don't know the most appropriate cure.

Re: possible bug with pango: and & or & in text string

Posted: 2019-09-04T07:54:03-07:00
by krukid
note that to avoid the weird handling of html entities and backslashes you can also pipe the text via stdin:

Code: Select all

echo -n "& text" | magick -define pango:markup=false pango:@- tmp.png