Page 1 of 1

text height

Posted: 2010-06-17T04:20:52-07:00
by immortal26
Hello all,

First off here is the code in php (via command):

Code: Select all

$compolay = 'convert  -size 1145x408\!  -rotate 180 -distort Arc "45, 150"  -gravity center -background none -fill "#FFFFFF40" -font '.$font.' label:"'.$text.'"  comp.png';
I'm wanting to keep the width so label can automatically resize the text to fit that width but I also know that it controls the pointsize of the font. So basically what I'm trying to do is let it keep doing what it's doing with the width but also i want it to ignore the aspect ratio of the width and give me the height I'm trying to put in... as in stretch the text up at the width given and height given.

Thanks

Re: text height

Posted: 2010-06-17T05:58:11-07:00
by snibgo
As far as I know, label etc can't stretch the text height. But you can stretch the text afterwards. For example, to fit text exactly into 500x500 (Windows script):

Code: Select all

convert ^
  -size 500x500 label:"Hello world" ^
  -trim +repage -resize "500x500^!" ^
  text.png

Re: text height

Posted: 2010-06-17T21:19:43-07:00
by anthony
WARNING Brain dump in progress... Content may be a little muddled, and off topic

text rendering does not make use of any aspect ratio settings (except posibly in -draw with canvas warping)
It just generates a 1:1 ratio as described by the font.

Of course fonts are not all the same height at a specific pointsize. Pointsize actually refers to 'line spacing' and not anything to do with the actual draw text, whcih is why I find so many fonts very small when compared with other fonts.

If you decide to resize the height (rather than pad it with -extent) make sure you include a '!' flag or resize also preserves the aspect ratio.

I would suggest you trim the label after you generate it a a specific width. pad the label width back to normal (-extent), perhaps add a small border for to space it a little from the trimmed edges, before resizing the height appropriately.

Exactly what you do however is up to you.

NOTE for a better quality with resizing. Create the label at a larger -density, Say twice the density and twice the width. Do the trim/pad/border stuff. then shrink the whole thing down to the actual final size.

Note I did not say double the pointsize but double the density. The two behave slightly differently with some fonts, though they have similar size effects.