问题描述
我在Mac上使用Graphviz,但是我的大多数应用程序都在具有Ubuntu的服务器上运行.我已经注意到,在不同的操作系统上编译时,具有相同源代码的点方案在绘制时会有所不同.
I'm working with Graphviz on Mac but most of my apps run on servers with Ubuntu. I've noticed that dot-schemes with the same source code are drawn a bit differently when compiled on different operating systems.
在我看来,主要原因是系统上字体之间的差异.即使我使用相同的通用字体和相同的大小-它们看起来也太不同了,这对版面有很大影响.
It seems to me that the main reason is the difference between fonts on the systems. Even though I use the same generic fonts and same sizes — they appear too different which affects the layout a lot.
所以问题是:是否可以在整个系统的Graphviz方案中使字体看起来相同?
So the question is: is it possible to make fonts look identical in Graphviz schemes across the systems?
下面我附上演示问题的示例.为了方便起见,图像被附加为链接.
Below I attach the examples demonstrating the problem. Images are attached as links for convenience.
源代码:
digraph {
graph [label="Mac" labelloc=t]
dpi=100
pad=0.2
rankdir=LR
a [shape=rect label="width=1" width=1]
b [shape=rect label="width=1.5 Arial" width=1.5 fontname=Arial]
c [shape=rect label="width=2.7 Arial 20" width=2.7 fontname=Arial fontsize=20]
d [shape=rect label="width=4 Helvetica" width=4 fontname=Helvetica]
e [shape=rect label="width=5 Helvetica 25" width=5 fontname=Helvetica fontsize=25]
f [shape=rect label="width=6, blue 0.8, red 0.2" width=6 style=filled color="blue:red;0.2" fontcolor=white]
}
- 在Mac上生成 graphviz版本2.40.1
- 在Ubuntu上生成 graphviz版本2.40.1
- 在Windows 10上生成 graphviz版本2.38
- Generated on Mac graphviz version 2.40.1
- Generated on Ubuntu graphviz version 2.40.1
- Generated on Windows 10 graphviz version 2.38
如您所见,字体不是唯一的问题:在Mac \ Ubuntu和Win10上,两种颜色的填充看起来有些不同.但这可能是因为我的Windows计算机上装有graphviz 2.38.
As you can see on the schemes — the font is not the only problem: filling with two colors looks a bit different on Mac\Ubuntu and Win10. But this specific issue may be because I have graphviz 2.38 on my Windows machine.
现在是相同的方案,但是没有节点标签:
And now the same scheme but without node labels:
digraph {
graph [label=Mac labelloc=t]
dpi=100
pad=0.2
rankdir=LR
a [shape=rect label="" width=1]
b [shape=rect label="" width=1.5 fontname=Arial]
c [shape=rect label="" width=2.7 fontname=Arial fontsize=20]
d [shape=rect label="" width=4 fontname=Helvetica]
e [shape=rect label="" width=5 fontname=Helvetica fontsize=25]
f [shape=rect label="" width=6 style=filled color="blue:red;0.2" fontcolor=white]
}
- 在Mac上生成 graphviz版本2.40.1
- 在Ubuntu上生成 graphviz版本2.40.1
- 在Windows 10上生成 graphviz版本2.38
- Generated on Mac graphviz version 2.40.1
- Generated on Ubuntu graphviz version 2.40.1
- Generated on Windows 10 graphviz version 2.38
这里的结果几乎相同(除了该死的颜色列表)
Here the resuts are almost identical (except the damn colorlist)
推荐答案
问题似乎出在自制软件. Graphviz在这里非常奇怪,特别是它不包含Cairo引擎,并且确实存在字体问题.
The problem seemed to be with graphviz version which is bottled in Homebrew. Graphviz is very strange there, especially it doesn't include Cairo engine and really has some problems with fonts.
因此,我已经删除了Homebrew版本,并从 MacPorts 安装了Graphviz 一个>.现在,当我在Mac上生成图像时,字体大小几乎与Ubuntu和Windows上的字体大小相同.字体并不完全相同,但它们足够接近开发过程.
So I have removed Homebrew version and installed Graphviz from MacPorts. Now the font sizes when I build images on Mac are almost the same as on Ubuntu and Windows. The fonts are not perfectly the same but they are close enough for the development process.
这篇关于Graphviz的可移植性和字体.如何使方案在不同的操作系统上相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!