Graphviz 找不到任何字体
使用 graphviz 执行任何操作时,我收到“无法找到/打开字体”错误。我已经将其范围缩小到尽可能简单的图表,在文件 simplest.dot
中:
digraph G {
node1
}
当运行 $ dot simple.dot -Tpng -O
时,图表是渲染为 simplest.dot.png
,但我总是收到此错误:错误:无法找到/打开字体
,并且输出中使用的字体不是很漂亮。
根据graphviz常见问题解答,当出现此错误时,您可以告诉graphviz在哪里寻找字体< /a>.我一直在我正在使用的系统上寻找字体,/usr/share/fonts
中似乎有一些 TrueType 字体,其中包括 Bitstream Vera 字体,这似乎位于/usr/share/fonts/bitstream-vera
。
因此,我尝试在点图中设置 fontpath
和 fontname
来帮助 graphviz 弄清楚问题:
digraph G {
fontpath="/usr/share/fonts/bitstream-vera"
fontname="Bitstream Vera Sans"
node1
}
但我仍然遇到完全相同的错误。我已经尝试了路径和字体名称的几种变体,但我似乎无法得到正确的结果。我做错了什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能是一个盲目的尝试,但在 http://www. graphviz.org/doc/info/attrs.html#d:fontname 它说如果您指定 fontname=schlbk,该工具将查找名为 schlbk.ttf 或 schlbk.pfa 或 schlbk.pfb 的文件在 fontpath 属性指定的目录之一中。
所以,我可能会尝试
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
在我的 macOS 上,可以执行以下操作:
On my macOS, the following works: