views:

250

answers:

1

I've been playing image generation on ImageMagick on Ubuntu 9.10. I want to be able to get it to recognize a font so that I may call it by it's "nickname".

I can find the list of fonts ImageMagick recognizes by typing

identify -list font

In that list I see Times-Bold. Therefore

convert -font Times-Bold label:abcdef times.gif

will generate a gif file with the Times New Roman Bold font.

I know I can pass the path to the font instead of it's nickname, but I need to be able to use its nickname so I have less errors when moving from system to system. The font I'm trying to get to work in particular is a true type font called Segoe UI.

I already have Segoe UI installed in my system. If I pass the path to the font it works. But I want to be able to use something like

convert -font Segoe-UI label:abcdef segoe.gif

Thanks!

+2  A: 

From what I remember, identify uses a configuration file, called type.xml, to locate fonts by name. You can alter imagemagick's own copy of this file at a system level, or add extra fonts in a user-level one.

There's a script called imagick_type_gen that will use the "locate" database to find fonts on your system and generate one of these configuration files, which you can then use to configure imagemagick; for an ordinary user I think this goes in ~/.magick/type.xml, though you can put it at a system level somewhere. This is generally what I've used in the past.

So, basically I think you need to configure your system type.xml file or add a user-level one. As long as you can do this when you move to a new system, for whichever user will be running imagemagick, you should at least be able to get away with not changing your code if the path to the font is different.

Matt Gibson
Excellent. Thank you Matt! For those semi-new to the command line, I executed the script by typing "./path/to/imagick_type_gen". I did make sure it was executable first by "sudo chmod +x /path/to/imagick_type_gen".
Ramon Tayag
I also had 2 types of fonts: Segoe UI Bold and Segoe UI. I was passing a "bold" parameter in the program I was using, RMagick but it wasn't getting bold. What I did was edit the file, and all stuff that pointed to the seguibd.ttf file (that's the bold version of Segoe UI), I changed the font family to a nickname I want. Not sure this is the best way, but it worked.
Ramon Tayag