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

发布于 2024-08-15 17:18:54 字数 1925 浏览 7 评论 0原文

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

有什么方法可以更改 graphviz 的默认字体大小吗?默认值为 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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亢潮 2024-08-22 17:18:54

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。

如果您尝试我上面的方法,但它似乎不起作用,请更改字体大小,在整个点文件中搜索“字体大小”设置,删除它们,然后将字体大小重新设置为节点属性。

这是完整的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文