Page 1 of 1

Text Align with Pango

Posted: 2013-12-12T11:42:41-07:00
by rafaelt
Hello!

I'm currently using ImageMagick with Pango and the image consists in a background with three texts.

A main text on the top and two others in the footer. I want them align on the right side, but I can't find a pango command to do so. I also tried "justify", just to see the effect and it didn't work. Am I doing anything wrong? My command is:

Code: Select all

    convert -size 390x30 -background transparent -define pango:justify=true pango:"footer 1" footer1.png
    convert -size 390x30 -background transparent -define pango:justify=true pango:"footer 2" footer2.png
    convert -size 390x390 -background transparent -define pango:wrap=word-char pango:"main text" main.png
    
    convert -size 512x512 \
            -page +0+0 /opt/images/backgrounds/green.png  \
            -page +61+61 -size 390x390 footer1.png \
            -page +55+447 -size 390x30  footer2.png \
            -page +55+465 -size 390x30  main.png \
            -layers flatten final-image.jpg
My questions are:

1. Am I doing anything wrong?
2. Is there a Pango+IM command to align footer #1 and footer #2 to the right?
3. Is there a Pango+IM command to vertical align the main text to the bottom?


Thanks a lot for your attention!

Re: TextAlign with Pango

Posted: 2013-12-12T11:52:17-07:00
by fmw42
I have not used PANGO, yet.

But for 3) add the IM command -gravity south.

You may try also -define pango:gravity=east for the alignment. But that is just a guess.

Re: Text Align with Pango

Posted: 2013-12-13T03:24:47-07:00
by rafaelt
For 3), when I use -gravity south, the text goes to the bottom but it also flips. I thought it was the normal behavior of -gravity south.

For -define pango:gravity=east, it does not change anything in the text alignment. Weird, huh? :?

I did not know about -define pango:gravity=east, I was trying -gravity from IM, but it does not seem to be the solution to my problems since when I try to generate images in Japanese or Chinese, for instance, the text goes to the right but each character rotates 90º to east, so they look like they were lying.

Re: Text Align with Pango

Posted: 2013-12-13T10:50:02-07:00
by fmw42
rafaelt wrote:For 3), when I use -gravity south, the text goes to the bottom but it also flips. I thought it was the normal behavior of -gravity south.

For -define pango:gravity=east, it does not change anything in the text alignment. Weird, huh? :?

I did not know about -define pango:gravity=east, I was trying -gravity from IM, but it does not seem to be the solution to my problems since when I try to generate images in Japanese or Chinese, for instance, the text goes to the right but each character rotates 90º to east, so they look like they were lying.



-define pango:gravity=east was just a guess on my part. I suppose it does not exist.

-gravity south in the IM command should not flip the text, only move it to the bottom.

Re: Text Align with Pango

Posted: 2013-12-13T11:02:20-07:00
by magick
Here are the defines that affect Pango rendering: -define pango:auto-dir=true/false, -define pango:ellipsize=start/middle/end, -define pango:gravity-hint=natural/strong/line, -define pango:hinting=none/auto/full, -define pango:indent=points, -define pango:justify=true/false, -define pango:language=en_US/etc, -define pango:markup=true/false, -define pango:single-paragraph=true/false and -define pango:wrap=word/char/word-char.