How to just render some text with the given font? Expecting something like:

echo "The slow cyan snail creeps under the eager cat" | render_text --font ./qqq.ttf --scale=18 -o text.png

I expect this to be somewhere in ImageMagick/GraphicsMagick suite.

Example use case: render the same text with multitude of fonts (and don't want to install all fonts into the system).

link|improve this question

64% accept rate
feedback

1 Answer

up vote 2 down vote accepted

You can use the convert command. If the font name has more than 1 word, separate them with a "-". Here are some examples using the Kid Kosmic font. Replace "YOURTEXT" with any phrase.


convert -pointsize 15 -font Kid-Kosmic label:"YOURTEXT" output.png

enter image description here


The caption: option enables text wrapping; but you need to specify the image size.

convert -pointsize 15 -font Kid-Kosmic -size 140x100 caption:"YOURTEXT" output.png

enter image description here


Another one with centered text:

convert -pointsize 15 -font Kid-Kosmic -size 140x100 -gravity center caption:"YOURTEXT" output.png

enter image description here

link|improve this answer
PANGRAM FAIL! – RedGrittyBrick Aug 11 '11 at 16:45
convert: unable to read font 'Kid-Kosmic' @ warning/annotate.c/RenderType/807... How to point it to the font file (without permanently installing it)? – Vi. Aug 12 '11 at 10:58
2  
Replacing "Kid-Kosmic" with the absolute path to a True Type font works for me on Ubuntu 11.04. What OS are you using? – flashnode Aug 12 '11 at 19:13
@flashnode It works for me too, I'm on Win7 Ultimate. Though I had to make sure the path is enclosed in double quotes. – Kaze Aug 12 '11 at 19:23
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.