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:
graph{
"test";
}
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
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
Now I tried to specify the height and the width directly on the node like this:
graph{
“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
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.
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.
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
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 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!