Node bounding box is way to big to node content


I am having an issue, with creating svg using Graphviz on an Azure machine.
I use the command dot -Tsvg myfile.txt
Having a VERY simple graph like this:


it renders perfectly on my own machine, but when I create it from my AppService in Azure, it looks like hits:

With -v, it gives:
dot - graphviz version 9.0.0 (20230911.1827)
libdir = “C:\home\site\wwwroot\Graphviz”
Activated plugin library: gvplugin_core.dll
Using render: svg:core
Using device: svg:svg:core

Activated plugin library: gvplugin_dot_layout.dll
Using layout: dot:dot_layout
The plugin configuration file:
was successfully loaded.
render : cairo dot dot_json fig gdiplus json json0 map mp pic pov ps svg tk xdot xdot_json
layout : circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
textlayout : textlayout
device : bmp canon cmap cmapx cmapx_np dot dot_json emf emfplus eps fig gif gv imap imap_np ismap jpe jpeg jpg json json0 metafile mp pdf pic plain plain-ext png pov ps ps2 svg tif tiff tk xdot xdot1.2 xdot1.4 xdot_json
loadimage : (lib) bmp eps gif jpe jpeg jpg png ps svg
pack info:
mode undefined
size 0
flags 0
margin 8
pack info:
mode node
size 0
flags 0
fontname: “Times-Roman” resolved to: (ps:pango Times New Roman, ) (PangoCairoWin32Font) “Times New Roman, 13.9990234375”
network simplex: 1 nodes 0 edges maxiter=2147483647 balance=1
network simplex: 1 nodes 0 edges 0 iter 0.00 sec
Maxrank = 0, minrank = 0
mincross: pass 0 iter 0 trying 0 cur_cross 0 best_cross 0
mincross %3: 0 crossings, 0.00 secs.
network simplex: 1 nodes 0 edges maxiter=2147483647 balance=2
network simplex: 1 nodes 0 edges 0 iter 0.00 sec
routesplines: 0 edges, 0 boxes 0.00 sec
Using render: svg:core
Using device: svg:svg:core
gvRenderJobs %3: 0.01 secs.

I guess it might be some environment variables or similar, which Graphviz is using, since it is the exact same version of Graphviz (9.0.0), and the same file I am trying to convert to svg.

Really hope someone can help me here,
thanks in advance :slight_smile:

Probably different fonts on the machine?

I tried with Helvetica as well, but same issue.
When I run it on my own machine, it also says:

fontname: “Times-Roman” resolved to: (ps:pango Times New Roman, ) (PangoCairoWin32Font) “Times New Roman, 13.9990234375”

So as far as I understand, it finds the same font on both machines :frowning:

For reference it looks like this on my own machine:


Try with -Tsvg:cairo. That uses different drawing backend that knows fonts better

Using -Tsvg:cairo only made it worse :confused:

Now I tried to specify the height and the width directly on the node like this:
“Test” [width=1, height=0.5];

Again it works perfectly on my local machine, but it totally ignores the width and height parameters, when run on Azure. Maybe that can help someone having a clue on what it is, or pointing me in some direction :confused:

Sometimes with svg we get a difference between fonts in the server and fonts in the browser. Might be worth trying to render to png with -Tpng to see a “server only” view of what’s going on.

Others may have traveled this road before: Font-Size different (LARGE) in Azure Web App · Issue #857 · Automattic/node-canvas · GitHub

It’s probably not that graphviz “totally ignores the width and height parameters”. More likely, it’s something like, the font rendering subsystem on a headless Azure node has its own, different definition of DPI or maybe DPI is invalid.

1 Like

When i try to render it as .png, it gives me this:

I guess that tells me, that it can not find the font? I have tried to google around, and I also found some places mentioning the sandboxes which Azure Web Apps are running in, has not the web-fonts installed.

I have tried playing around with adding my own custom font. But have not been able to make it work.
Is it correctly understood, that I have to install the font to be able to use it. It is not possible to just add a fontpath in my graph, to a ttf file?

If I’m not mistaken, font lookup is always? done through fontconfig. fontconfig can be controlled through environment variables, and it has some runtime debugging options and path control settings. This writeup seems promising.

To my understanding fontconfig uses fontconfig_path, when it is build.
So to be able to add a new directory, it will require me to make a new dll for fontconfig, instead of the one shipped with Graphviz.

This has to be done in a Linux environment, and I am sitting on a Windows machine.
It really seems like a lot of work-around/hassle to be able to provide your own ttf file, and to be honest I am not sure I have the capabilities to do this.

It is sad, since I really prefer Graphviz, and it works perfectly on my own machine. But I am currently leaning towards using Mermaid.js, since it does not depend on the server, eventhough I think Graphviz functionality wise is much better :frowning:

BTW, it should still be possible to set fontpath in the graph file. It should be possible to set the file name in fontname. At least, someone said that worked 12 years ago.

I have actually been past that post, and tried it, and it does not work like that anymore.
It says here: fontpath | Graphviz - Used if Graphviz was not built with the fontconfig library.
So I think the post 12 years ago, is from before Graphviz utilized fontconfig.

I am however also in doubt if this is actually my problem.

In AZURE, if I try to use Arial and run “dot.exe -v -Tsvg -o .svg”
Get the following line in my output:

  • "fontname: “Arial” resolved to: (PangoCairoWin32Font) “Arial 13.9990234375"”

While if I try to run it with a weird/unknown font name, I get

  • (dot.exe:18568): Pango-WARNING **: couldn’t load font “WeirdFontName Not-Rotated 14”, falling back to “Sans Not-Rotated 14”, expect ugly output.
    fontname: unable to resolve “WeirdFontName”

So unless this does not really mean, that it can find the font, but just that it can match it in some list of names, then it can actually find the font.

But I still get this results for .png file, so I am quite confused at the moment:

When I removed the “Fontconfig.dll” file from the Graphviz folder/version I had downloaded, it started working on Azure AppService as well! I am not sure why, but it makes it unable to use pango, and then the default when that is not working, is apparently looking a better place :slight_smile: I have not added anything else, like ie environment variables or fontpath, I just removed that dll.

@scnorth and @mark Thank you very much for all the suggestions, even though it was not directly any of them, which solved it, it was a huge help!