Graphviz portability and fonts. How make schemes i

2019-08-05 16:28发布

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.

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.

Source code:

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]
}

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]
}

Here the resuts are almost identical (except the damn colorlist)

1条回答
倾城 Initia
2楼-- · 2019-08-05 16:49

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.

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.

Same image generated by Graphviz from MacPorts

查看更多
登录 后发表回答