Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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).

share|improve this question
add comment

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

share|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. –  Ellesa Aug 12 '11 at 19:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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