graphvizdotfontconfig

Graphviz - dot fails with fontconfig error


A problem I had with Graphviz yesterday - I couldn't find anything documenting this exact error on Stack Overflow or elsewhere, so I decided to write it up.

On Linux, every call to dot started failing with the error message:

No fonts found; this probably means that the fontconfig
library is not correctly configured. You may need to
edit the fonts.conf configuration file. More information
about fontconfig can be found in the fontconfig(3) manual
page and on http://fontconfig.org

But checking /etc/fonts, the location of the three fontconfig files:

/etc/fonts/fonts.conf
/etc/fonts/fonts.dtd
/etc/fonts/conf.d

showed them all to be in the right place.

The fontconfig command fc-list also gave a non-empty list of installed fonts.


Solution

  • If a folder named .fontconfig exists in the user's home directory, Graphviz will default to using the fonts installed in that directory instead of using those installed under /etc/fonts

    In my case, somehow an empty directory ~/.fontconfig had been created without my knowledge. Copying all content from /etc/fonts to this directory solved the problem, as did deleting the ~/.fontconfig directory.