2009-12-21 990 views
21

我使用doxygen + graphviz來記錄我的代碼。 graphviz在生成圖像方面做得很好。如何更改graphviz的默認字體大小?

有沒有辦法改變graphviz的默認字體大小?默認值是14,但我想用12代替。

它是一個真正的痛苦來改變字體大小個別元素,例如,節點,子圖,邊......等

UPDATE:

僅供參考這裏是我使用的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 

回答

34

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設置爲節點屬性將覆蓋字體大小設置爲圖形屬性(僅適用於節點),並且爲特定節點設置字體大小將覆蓋爲所有節點設置的字體大小。

如果您嘗試了上面的內容,但似乎無法正常工作,請更改字體大小,搜索您的整個點文件以查找「字體大小」設置,將其刪除,然後將字體大小重新設置爲節點屬性。

這裏是完整的graphviz attribute list

+3

我試過這個,但它不適合我。 :( – chronodekar 2009-12-31 03:18:43

+0

自從我研究這個以來已經有一段時間了,我認爲我最終放棄了。但是,你的更新看起來可行,而且缺少更好的東西,我將其標記爲答案 – chronodekar 2010-02-25 05:39:13

+1

嘗試將雙引號括起來字體名稱?這對我有效 – 2013-02-21 15:54:44