Number: 1431
Title: Error: Could not find/open font
Submitter: Marcin Balcerzak
Date: 3 Sept 2008
Subsys: Output generation
Version: 2.20.2
System: amd64, Linux 2.6.24-gentoo-r8
Severity: minor
Problem: "dot -Tpng -o foo.png foo" generates fine looking png but also few lines of "Error: could not find/open font" (without specifying which). Neither "fc-cache" nor "fc-cache -f" does help. Reinstalling graphviz doesn't help (it's rebuilt from sources with fontconfig support of course). The same artifact doesn't occur with graphviz 2.18 - the older version works fine.
digraph G {
0 -> 1 [arrowsize=0.5,arrowtail=none]
0 -> 2 [arrowsize=0.5,arrowtail=none]
1 [label="a"]
2 [label="b"]

This message is coming from libgd, so the first question is why isn't it using pango/cairo to generate png images? Were there any warnings from ./configure ?

Could you send the stderr output of "dot -v -Tpng:cairo -o foo.png foo " please? [marcin] I enclose config.log and part of build.log. Apart from

expr: syntax error
configure: WARNING: Optional DevIL library not available - missing headers
configure: WARNING: Optional DevIL library not available
./configure: line 35095: ./po/ No such file or directory
I see nothing suspicious.

Result of "dot -v -Tpng:cairo -o foo.png foo" on stderr (foo.png is not generated):
Activated plugin library:
Using textlayout: textlayout:gd
Activated plugin library:
Using layout: dot:dot_layout
Activated plugin library:
Using render: xdot:core
Format: "png:cairo" not recognized. Use one of: png:gd:gd

Both "dot -v -Tpng:gd:gd -o foo.png foo" and "dot -v -Tpng:gd -o foo.png foo" result in (+ generation of foo.png but in poor quality): Activated plugin library: Using textlayout: textlayout:gd Activated plugin library: Using layout: dot:dot_layout Using render: gd:gd Using device: png:gd:gd The plugin configuration file: /usr/lib64/graphviz/config was successfully loaded. render : dot fig gd map ps svg tk vml vrml xdot layout : circo dot fdp neato nop nop1 nop2 twopi textlayout : textlayout device : canon cmap cmapx cmapx_np dia dot eps fig gd gd2 gif hpgl imap imap_np ismap jpe jpeg jpg mif mp pcl pic plain plain-ext png ps ps2 svg svgz tk vml vmlz vrml vtx wbmp xdot loadimage : (lib) gd gd2 gif jpe jpeg jpg png ps svg xbm Error: Could not find/open font fontname: "Times-Roman" resolved to: [internal times] Error: Could not find/open font Error: Could not find/open font network simplex: 3 nodes 2 edges 0 iter 0.00 sec mincross: pass 0 iter 0 trying 0 cur_cross 0 best_cross 0 mincross G: 0 crossings, 0.00 secs. network simplex: 5 nodes 5 edges 0 iter 0.00 sec routesplines: 2 edges, 6 boxes 0.00 sec Using render: gd:gd Using device: png:gd:gd dot: allocating a 27K PaletteColor GD image

[ellson] OK, so here is the first problem. Apparently you are configuring with: --without-pangocairo ??? I strongly recommend that you don't do that. Also you have: --without-cgraph which you should definitely omit altogether. We are migrating the code to cgraph; the default will always be what you want, but we will change the default at some point, so don't override it.

As to why libgd isn't resolving fonts correctly, I think it may be because your libgd was not built with fontconfig support. You should be able to see by running: /usr/bin/gdlib-config --features

I can't reproduce the problem with the latest snapshots and with Fedora's gd-2.0.35-6 which does have fontconfig support.

You might try building from a nightly snapshot, that way you can take immediate advantage of any fixes we provide.

[marcin] The apparent bug was due to my lack of knowledge on how to configure graphviz to make it work. Thanks for help. What I finally did:

1) gd was without fontconfig support  - I reinstalled it so now
# /usr/bin/gdlib-config --all
GD library  2.0.35
includedir: /usr/include
cflags:     -I/usr/include
ldflags:      -L/usr/lib64  -L/usr/lib64
libs:       -lXpm -lX11 -ljpeg -lfontconfig -lfreetype -lpng12 -lz -lm
libdir:     /usr/lib64
2) I enforced cairo, pango, cgraph, gd (should anyone ask you: in gentoo it's turning on USE flags - cairo, pango, cgraph) support for graphviz. I usually try to not have too many crazy USE flags turned on (there are hundreds of them and they often enforce installation of some packages etc so turning many makes you ending with clobbered system with loads of unnecessary stuff) and I was not aware that without them graphviz won't run properely.  And now it's configured:
./configure --prefix=/usr --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --enable-ltdl --with-x --with-cgraph --with-gtk --with-pangocairo --without-ming --with-digcola --with-ipsepcola --with-fontconfig --with-freetype2 --with-libgd --without-gdk-pixbuf --without-sfdp --without-smyrna --without-digcola --without-ipsepcola --without-gnomeui --disable-guile --disable-java --disable-io --disable-lua --disable-ocaml --enable-perl --disable-php --enable-python --disable-r --enable-ruby --disable-sharp --enable-tcl --libdir=/usr/lib64 --build=x86_64-pc-linux-gnu

Now it works ok.

Maybe it's worth adding to FAQ that gentoo users should have turned USE flags: cairo, cgraph, fontconfig, gd, graphviz, pango and only after then install things like cairo, fontconfig, gd, pango, graphviz.

Once again thank you for help.

[ellson] You have both "--with-digcola --with-ipsepcola" and "--without-digcola --without-ipsepcola" ! These flags were only introduced because of concerns about the portability of the C++ code in the ipsecola algorithm. This is not a problem on modern linux systems. The algorithms are used by neato. I recommend that you use just: "--with-digcola --with-ipsepcola"

If you'd care to write a gentoo user's FAQ paragraph or two for our web pages, I'd be pleased to add them for you. I'd rather you didn't ask me to write them since I'm sure I would get it wrong.

[marcin] The parameters to ./configure are set automatically by portage (Gentoo package manager). It is heavily influenced by inter alia set of USE flags and either some of these should not be turned on simmultaniously or some is off when should be on or this artifact is a real bug in Gentoo. I've never used neato. I don't have really time to track this now but could you write me some short test checking if neato is working properely or it'd be better to get rid of these withoutcolas (in that case I may investigate this more and possibly rewrite Gentoo tip in FAQ). Thanks.

A "FAQ paragraph or two" is maybe too high-sounding name, but a short tip for Gentoo people:

To have Graphviz properely installed on Gentoo, it is recommended to have these USE flags: cairo, cgraph, fontconfig, gd, graphviz, pango, and emerge with them both graphviz and packages used by it (like: cairo, fontconfig, gd, pango). Not doing so can result in reduction of Graphviz functionality, which sign may be e.g. bug 1431
Owner: ellson
Status: Fixed (3 Sept 2008)