Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphviz not supporting UTF-8 encoding

I have created a dot file.which contain some korean language in some node's label .i created png file with help of graphvig tool but that created png doesn't support korean language it appear as square box. if i create svg file then it works fine. help me how to resolve this.

like image 677
Ashish Avatar asked Jul 19 '11 07:07

Ashish


3 Answers

I met the same problem, and adding the following lines helped me:

strict digraph { 
node [ fontname="Adobe Kaiti Std" ];
edge [ fontname="Adobe Heiti Std" ];
} 
like image 199
youkaichao Avatar answered Oct 19 '22 21:10

youkaichao


I had the same problem, when a .png file is generated, the non-ascii chars is not rendered correctly.

My alternative solution is to use the .svg output (via some command like: dot -Tsvg my_graph.gv), which left the font-finding problem to the svg viewer.

You can open the .svg file with a Web Browser. And most Web Browser also support the save as function to convert the .svg file to .png if you insist on the .png format.

Hope this helpful

like image 33
luochen1990 Avatar answered Oct 19 '22 19:10

luochen1990


Also try running dot -v to see what plugins and font files are being loaded. Generally we expect UTF-8 to work (a lot of work was done on this over the years), and text layout through the cairopango driver works well. A downside is that pango now does its own font lookup which is somewhat of a black box to other code. (pango recently dropped fontconfig, which is understandable. We did not ever discover a way to determine if fontconfig failed to find a good match for a given specification - it would cheerfully return e.g. a typewriter font when it could not find any other match.) Hope this helps a little. Stephen North (for the graphviz project)

like image 5
Stephen North Avatar answered Oct 19 '22 20:10

Stephen North