I'm getting "Could not find/open font" errors when doing anything with graphviz. I've been narrowing it down to an as simple graph as possible, in the file simplest.dot
:
digraph G {
node1
}
When running $ dot simplest.dot -Tpng -O
the graph is rendered to simplest.dot.png
, but I always get this error: Error: Could not find/open font
, and the font used in the output isn't very pretty.
According to the graphviz faq, when this error occurs, you can tell graphviz where to look for fonts. I've been looking around for fonts on the system I'm using, and there seem to be some TrueType fonts in /usr/share/fonts
, among others, the Bitstream Vera fonts, which seem to live in /usr/share/fonts/bitstream-vera
.
So I've tried setting fontpath
and fontname
in the dot graph, to help graphviz figure things out:
digraph G {
fontpath="/usr/share/fonts/bitstream-vera"
fontname="Bitstream Vera Sans"
node1
}
But I'm still getting the exact same error. I've tried several variations of the path and font name, but I can't seem to get it right. What am I doing wrong?
This might be a shot into the dark, but in http://www.graphviz.org/doc/info/attrs.html#d:fontname it says If you specify fontname=schlbk, the tool will look for a file named schlbk.ttf or schlbk.pfa or schlbk.pfb in one of the directories specified by the fontpath attribute.
So, I'd probably try
digraph G {
fontpath="/usr/share/fonts/bitstream-vera"
fontname="nameOfttfWITHOUTsuffix.ttf"
node1
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With