Pop Culture•Music•Travel•Fashion•Sports•Money•Tech
Thursday February 16th 2012

Fixing OS X Font Errors In ImageMagick

We installed ImageMagick on Mac OS X 10.4.11 using MacPorts. Everything worked great except for the text. If you run the convert command and try to draw text you get this message:

convert: unable to read font `/Library/Fonts/Arial' @ annotate.c/RenderFreetype/1044.

Open up fontbook and find where you fonts are by right clicking on a Font. Arial is indeed at /Library/Fonts/Arial. What’s up with that?

Apparently ImageMagick doesn’t understand the OS X font format, dfont. Mac OS X dfonts are like directories which bundle together all the styles of a font. So the solution is to convert the dfont-format fonts to something ImageMagick understands, stick them somewhere and then tell ImageMagick where they are.

Install and Run Fondu
We can convert the fonts using fondu. First install Fondu using MacPorts:

sudo port install fondu

This finished in a jiffy. Then make a directory to hold the fonts, cd to that directory and run fondu. Requires sudo.

cd /usr/local/share/fonts/
sudo fondu /Library/Fonts/*.dfont

Get and Run imageMagick_type_gen.pl
This is a perl script from ImageMagick.org that creates the type.xml file which tells it which fonts are available. Read the script and find instructions for running it with the unix find command so you can tell it where you fonts are. Basically you have to end up with a good type.xml file. For some readon I had to edit the output in vi to get it exactly right. It left off the xml tags for some reason.

Next either replace the original type.xml or stick a local version in ~/.magick/type.xml
I found the original in the installation directory for Imagemagick at /opt/local/lib/ImageMagick-6.5.9/config/type.xml
Sticking it in the .magick directory didn’t seem to work for me, so I replaced the original. Requires sudo.

After this, I was able to use my fonts.

This solution came from Using OS X fonts in ImageMagick on Gothick.org, which is Matt Gibson’s Personal Pages. Thanks and a hat tip to Matt.

More from category

Unix: How to Automate Thumbnails
Unix: How to Automate Thumbnails

Use a shell script to automate the creation and uploading of thumbnails. [Read More]

Wordpress: How to Disable Post Revisions
Wordpress: How to Disable Post Revisions

By disabling post revisions in Wordpress, it reduced the database size and allowed the wordpress MySQL database backups [Read More]

Wordpress: How to Target Ads for Different Categories
Wordpress: How to Target Ads for Different Categories

Display different ads in each categories in your Wordpress blog. [Read More]

LBB 2010 Annual Report to Shareholders
LBB 2010 Annual Report to Shareholders

2010 Web Server Report for Laguna Beach Bikini [Read More]

LBB Webserver Status Bulletin

LBB was offline due to corrupted mySQL database. The tables were repaired and the blog is back online [Read More]

Advertisement

LBB Stats