Graphviz Can't Find Any Fonts

Graphviz can't find any fonts

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

digraph G {
fontpath="/usr/share/fonts/bitstream-vera"
fontname="nameOfttfWITHOUTsuffix.ttf"
node1
}

Graphviz: change font for the whole graph?

No, there is no other way.

As in the forum post you linked, you have to define the default values separately (like the other attributes) at the beginning of your graphviz file:

digraph g {
graph [fontname = "helvetica"];
node [fontname = "helvetica"];
edge [fontname = "helvetica"];
...
}

How do I set the Cluster font attributes in Graphviz?

fontname is working for cluster labels.

Here's an example with illustration - it's quite simple, just set it before setting the content of the label.

digraph g{
node[fontname="Impact"];
subgraph cluster0 {
"Cluster node";
fontname="Courier";
label="Cluster label";
}
fontname="Arial";
label="Graph Label";
}

The result:

graphviz output showing the effect of fontname on a cluster

Graphviz _ installation and the instruction for use

If you followed the default installation options...

Sample Image

...then GraphViz will be installed here:

C:\Program Files\Graphviz

To verify this, you can run one of the programs it uses - such as dot.exe.

1 - Open a command promt.

2 - Run the following command:

"C:\Program Files\Graphviz\bin\dot" -V

Note the uppercase V.

That will print the installed version number to confirm that the installation was succesful:

dot - graphviz version 4.0.0 (20220529.0937)

After that, you can create dot files (you can find a tutorial for that) and run them at the command line.


Update

Here is a simple example of creating a graph after completing the installation:

I will choose a directory in which to work, to keep my work separate from the installation directory:

C:\Users\me\graphviz-work

In this directory I create the following text file called demo.dot. I create this file manually using Notepad++, and just type it all in:

digraph G {
main -> parse -> execute;
main -> init;
main -> cleanup;
execute -> make_string;
execute -> printf
init -> make_string;
main -> printf;
execute -> compare;
}

In the same directory, at the command line, I run the following command to generate the graph from this file:

"C:\Program Files\Graphviz\bin\dot" -Tsvg demo.dot -o demo.svg

This generates the output file demo.svg:

Sample Image

This example is taken from the dot user's manual.


Everything I have shown here involves working at the command line (and editing text files by hand), and using the various Graphviz tools directly. As you have seen, you don't have to do this. You can use a tool such as Visual Studio to make things more convenient; you can use languages such as Python which allow you to build graphs programmatically (without you needing to directly interact with GraphViz).

So, there are various different ways to use GraphViz. Personally, I think it helps to understand the basics (as shown here) before using another tool.

how to change default font size for graphviz?

Fontsize is a graph attribute (as well as an edge and node attribute). Doxygen generates a dot file, so, e.g.,:

strict digraph {
graph [ bgcolor=lightgray, resolution=128, fontname=Arial, fontcolor=blue,
fontsize=12 ];
node [ fontname=Arial, fontcolor=blue, fontsize=11];
edge [ fontname=Helvetica, fontcolor=red, fontsize=10 ];

}

Specific settings will override generic ones; hence setting fontsize as a node attribute will override the fontsize set as a graph attribute (just for nodes though), and setting fontsize for specific nodes will override fontsize set for all nodes.

If you try what i have above and it does not seem to work, change the fontsize, search your entire dot file for 'fontsize' settings, remove them, and re-set fontsize as a node attribute.

Here is the complete graphviz attribute list.

How do you change the font background color of just part of a GraphViz label?

It requires creating an HTML table with one cell with desired background color.

digraph G {

"A" -> "B" [label=<This is my label <br/> It has line breaks. I <FONT COLOR="Red">love</FONT> background<br/>Colors.>]

C [label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0">
<TR><TD COLSPAN="3">This is my label </TD></TR>
<TR><TD>It has line breaks. I </TD><TD BGCOLOR="red">love</TD><TD>background</TD></TR>
<TR><TD COLSPAN="3">Colors</TD></TR>
</TABLE>>]
}

Giving:

Sample Image

Graphviz as a standalone OS independent standard executable

Since I'm using Electron to integrate with Graphviz and use on any OS. I'm using a node module that works beautifully with Graphviz and also supports the HTML-like label (expat library) too.



Related Topics



Leave a reply



Submit