Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imagemagick font_stretch or spacing between letters?

I am generating some buttons using ImageMagick. However, I am not able to set the spacing between the letters in generated image. Command which I use:

convert -gravity center button_subscribeme.png -font /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf  -fill white -draw "text 0,0 'CLICK ME'"  -font_stretch 10  render/mailbox-submit.png

throws:

convert: unrecognized option `-font_stretch' @ error/convert.c/ConvertImageCommand/1561.

So I guess font_strech is not proper option. How I can achieve it? Generated text is too narrow.

like image 985
bluszcz Avatar asked Jan 15 '23 23:01

bluszcz


1 Answers

There is no ImageMagick parameter named -font_stretch that I know of. However, there is -stretch.

But I don't think that -stretch really works with fonts. In any case, to find out what sort of values are possible, just run:

convert -list stretch

and see the result:

Any
Condensed
Expanded
ExtraCondensed
ExtraExpanded
Normal
SemiCondensed
SemiExpanded
UltraCondensed
UltraExpanded

Use -kerning !

Better use the -kerning commandline parameter. It takes positive as well as negative values:

convert \
  in.png \
 -gravity center \
 -font "/Library/Fonts/Arial Bold.ttf" \
 -kerning -0.5 \
 -fill white \
 -draw "text 0,0 'CLICK ME'" \
  out1.png

or

convert \
  in.png \
 -gravity center \
 -font "/Library/Fonts/Arial Bold.ttf" \
 -kerning 1.5 \
 -fill white \
 -draw "text 0,0 'CLICK ME'" \
  out2.png

Works for me on ImageMagick version 6.7.8-3 2012-07-19 on Mac:

<code>-kerning -0.5</code> <code>-kerning 1.5</code>

like image 189
Kurt Pfeifle Avatar answered Jan 31 '23 05:01

Kurt Pfeifle