如何改变graphviz的默认字体大小?

时间:2009-12-21 04:34:37

标签: doxygen graphviz

我使用doxygen + graphviz来记录我的代码。 graphviz在生成图像方面做得很好。

有没有办法更改graphviz的默认fontsize?默认值为14,但我想使用12代替。

更改单个元素(如节点,子图,边缘等)的字体大小真是太痛苦了。

更新:

这里的参考是我在doxygen中使用的代码,(文本字段已经重命名,当然)

@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

1 个答案:

答案 0 :(得分:37)

Fontsize是图形属性(以及边缘和节点属性)。 Doxygen会生成一个点文件,例如:

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

                }

特定设置将覆盖通用设置;因此,将fontsize设置为节点属性会将fontsize设置为图形属性(仅适用于节点),而为特定节点设置fontsize将覆盖为所有节点设置的fontsize。

如果您尝试上面的内容并且似乎不起作用,请更改fontsize,在整个点文件中搜索“fontsize”设置,删除它们,然后将fontsize重新设置为节点属性。

以下是完整的graphviz attribute list