【问题标题】:how to change default font size for graphviz?如何更改graphviz的默认字体大小?
【发布时间】:2010-12-28 15:13:48
【问题描述】:

我使用 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

【问题讨论】:

  • 以下有用的问题和答案+1!

标签: doxygen graphviz


【解决方案1】:

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 将覆盖为所有节点设置的字体大小。

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

这是完整的graphviz attribute list

【讨论】:

  • 我已经有一段时间没有研究这个了,我想我最终放弃了。不过,您的更新看起来是可行的,由于没有更好的东西,我将其标记为答案。
  • 尝试在字体名称两边加上双引号?这对我有用。
  • 我使用的是graphviz页面上描述的labelfontcolor,但没有运气。 fontcolor 工作正常,谢谢。
猜你喜欢
  • 2012-06-12
  • 1970-01-01
  • 2012-08-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-25
相关资源
最近更新 更多