Fontname is ignored if output format is eps

Hi everybody,

I'm using R (version 3.1.2 for Windows) to create a dot-file. I execute this dot-file via the command promt and it doesn't give me a warning or an error-message, but it doesn't do, what I want. I want, that the text in the nodes is in arial font but when I execute the file I get nodes with text in some other font (I even don't know which one it is...).
Hopefully you can help me to fix this problem!

Here's an example:

Dot-File named FILENAME

digraph G{
node [fontname = "Arial"]
"A" [label="A\na\nn = 1"];
"B" [label="B\nb\nn = 2"];
"C" [label="C\nc\nn = 3"];
"D" [label="D\nd\nn = 4"];
"E" [label="E\ne\nn = 5"];
"A" [color="lightblue2", style=filled];
"B" -> "A" [color = "blue"]
"C" -> "A" [color = "red"]
"E" -> "D" [color = "red"]
"D" -> "C" [color = "red"]
"D" -> "B" [color = "red"]
"E" -> "B" [color = "blue"]

And my call in command promt is:

dot -Teps -o epsTest.eps -Gsize=20,100 -Nfontname=Arial

So I tell the graph to use arial font two times and this works fine if I'm using png or pdf as output format but with eps this is ignored...

Thanks for your help in advance,

Dot uses the font information

Dot uses the font information it has to determine the layout. In the generated postscript, it tells the postscript interpreter to load the Arial font. As this is done in real-time by the interpreter, it has to determine what to do with the request for Arial if this font is not available to it. It is likely picking Courier or some standard sans serif font. This is also a problem with SVG output, or any output format where the fontname is given to the viewer to interpret. 

One way around this is to make an Arial font available for the postscript viewer you are using. A simpler solution is to generate postscript using the cairo renderer -Tps:cairo. This gets around the problem by embedding the required fonts in the output.

Problem solved :)

Hi erg,

thank you for your helpful answer!

I opened the *.eps-file in an other viewer and, you are right, it shows Arial font in the nodes! I'm really glad it wasn't a programming mistake I made. I tried your second suggestion as well but I'm not so happy with it. If I generate a *.ps file, zooming in leads to kind of ugly graphs - the lines get very pixelated which they don't do when I save them as *.eps.

Well, thanks again for you answer. I think I'll take the other viewer, hence I don't have to install any plug-ins.


Recent comments