Installing fonts on GUI-less Linux for wkhtmltoimage

Posted on

Problem :

I’m having difficulties getting wkhtmltoimage to recognize fonts not installed on my CentOS 5.8 box.

I’ve tried installing the font I need (Verdana) via .rpm but that didn’t seem to work.

I tried various webfont embedding methods and that didn’t work either.

Does anyone know if I need to have GUI software installed (X11, Gnome, etc.) to allow wkhtmltoimage to use the fonts installed on the OS?

The fonts installed by the .rpm are found in:


Edit: Running fc-cache -f -v

/usr/share/fonts: caching, 0 fonts, 3 dirs
/usr/share/fonts/bitstream-vera: caching, 10 fonts, 0 dirs
/usr/share/fonts/default: caching, 0 fonts, 2 dirs
/usr/share/fonts/default/Type1: caching, 35 fonts, 0 dirs
/usr/share/fonts/default/ghostscript: caching, 8 fonts, 0 dirs
/usr/share/fonts/msttcore: caching, 31 fonts, 0 dirs
/usr/share/X11/fonts/Type1: skipping, no such directory
/usr/share/X11/fonts/OTF: skipping, no such directory
/root/.fonts: skipping, no such directory
/var/cache/fontconfig: cleaning cache directory
/root/.fontconfig: not cleaning unwritable cache directory
fc-cache: succeeded

I’m afraid wkhtmltoimage still doesn’t use my Verdana font.

Solution :

I had this problem and just fixed it.

Please follow this way :

rpm -Uvh msttcore-fonts-2.0-3.noarch.rpm

then it will show correct type of lots of fonts.

And don’t forget , For Centos that has not GUI libraries , You should install complete list of GUI libraries to get better results.

Leave a Reply

Your email address will not be published. Required fields are marked *