how to change default font size for graphviz?

39,804

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.

Share:
39,804
chronodekar
Author by

chronodekar

Looking for work as a web developer in the Toronto area.

Updated on February 22, 2020

Comments

  • chronodekar
    chronodekar over 4 years

    I use doxygen + graphviz for documenting my code. graphviz does a nice job of generating images.

    Is there any way to change the default fontsize for graphviz? The default is 14, but I want to use 12 instead.

    Its a real pain to change the fontsize for individual elements like, nodes, subgraphs, edges ... etc.

    UPDATE:

    For reference here is the code I'm using in doxygen, (the text fields have been renamed, of course)

    @dot
     strict digraph {
       node [shape = box, fontsize = 12];
         subgraph cluster_main {
           fontsize = 12;
           shape    = box;
           label    = "main";
           subgraph cluster_main_common {
             fontsize = 12;
             shape    = box;
             label    = "common";
             subgraph cluster_main_common_source {
               fontsize = 12;
               shape    = box;
               label    = "source"
               subgraph cluster_file1 {
                 fontsize = 12;
                 shape    = box;
                 label    = "file1.c";
                 gSystem [label = "var1" URL = "\ref var1"];
               }
               subgraph cluster_file2 {
                 fontsize = 12;
                 shape    = box;
                 label    = "file2.c";
                 gCard [label = "var2" URL = "\ref var2"];
               }
               subgraph cluster_file3 {
                 fontsize = 12;
                 shape    = box;
                 label    = "file3.c";
                 gPwrSupply [label = "var3" URL = "\ref var3"];
               }
             }
           }
           subgraph cluster_main_docs {
             fontsize = 12;
             shape    = box;
             label    = "docs";
             subgraph cluster_main_docs_features {
               fontsize = 12;
               shape    = box;
               label    = "features";
               subgraph cluster_main_docs_features_source {
                 fontsize = 12;
                 shape    = box;
                 label    = "source"
                 subgraph cluster_file4 {
                   fontsize = 12;
                   shape    = box;
                   label    = "file4.c";
                   deviceInfo [label = "var4" URL = "\ref var4"];
                 }
               }
             }
           }
         }
       }
       @enddot
    
  • chronodekar
    chronodekar over 14 years
    It's been a while since I looked into this, and I think I gave up in the end. Nevertheless, your update looks workable and for lack of anything better I'm marking this as the answer.
  • Josh Petitt
    Josh Petitt over 11 years
    try putting double quotes around the font name? This worked for me.
  • user2023370
    user2023370 over 8 years
    I was using labelfontcolor described on the graphviz page, with no luck. fontcolor works fine though, thanks.