Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagickError unable to read font `(null)': `(null)'

I've been getting this error for a while on my production server (Ubuntu running ImageMagick, Rmagick, etc).

From Googling around it seems to be not finding the right fonts to use, and this needs to be set correctly in

sudo nano /usr/lib/ImageMagick-6.3.7/config/type-ghostscript.xml

When I open up this file it lists a bunch of fonts in this directory

/usr/share/fonts/type1/gsfonts/

They all exist. I've tried changing the owner and permissions on those fonts. Doesn't seem to help.

Has anyone encountered this and been able to fix it? Thanks!

like image 762
Brian Armstrong Avatar asked Jun 18 '09 18:06

Brian Armstrong


1 Answers

Finally solved it after MONTHS!!

Answer was here: http://rubyforge.org/forum/forum.php?thread_id=8742&forum_id=4402

Had to compile imagemagick with the "--with-gs-font-dir=/where/your/gs/fonts/live" flag

did a "locate .pfb" to find where they were. for me it was "--with-gs-font-dir=/usr/share/fonts/type1/gsfonts" on ubuntu

Complete steps below. Note I had to use the "–disable-openmp" flag also due to another bizarre error described here: http://computerplumber.com/2009/01/installing-rmagick-28-gem-on-hardy/

# remove in case you already installed imagemagick from apt-get
sudo apt-get remove imagemagick
sudo apt-get install libperl-dev gcc libjpeg62-dev libbz2-dev libtiff4-dev libwmf-dev libz-dev libpng12-dev libx11-dev libxt-dev libxext-dev libxml2-dev libfreetype6-dev liblcms1-dev libexif-dev perl libjasper-dev libltdl3-dev graphviz gs-gpl pkg-config

#get image magick from source and compile it
cd ~/sources
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
cd ImageMagick-6.5.4-2
./configure --disable-openmp --with-gs-font-dir=/usr/share/fonts/type1/gsfonts
make
sudo make install

#reinstall rmagick gem
sudo gem uninstall rmagick
sudo gem install rmagick

This has been possibly the worst install experience I've ever encountered in my life due to this and numerous other bugs. Shame on imagemagick and rmagick.

like image 67
Brian Armstrong Avatar answered Sep 29 '22 22:09

Brian Armstrong