Fontsize fontname fontcolor all ignored

qq.dot

This is my test graph:

digraph "TEST" {
    node [shape = ellipse, style = solid]
    edge [style = solid]

        blackrect {
            fontsize = 21.0
            fontname = "Bookman-LightItalic"
            fontcolor = black
            shape = rectangle
            style = solid
        }
        bigblue {
            fontsize = 27.75
            fontname = "Monospace"
            fontcolor = "blue"
            shape = ellipse
            style = solid
        }
        smallgreen {
            fontsize = 8.25
            fontname = "serif"
            fontcolor = "green"
            shape = ellipse
            style = solid
        }
        bigblue -> smallgreen {
            fontsize = 10.75
            fontname = "Inconsolata:style=Regular"
            fontcolor = black
            color = "red"
            style = solid
        }
    }

I installed graphviz using conda, and the output uses a single font and color for all objects. The output from dot -v -Kdot -Tpng testgraph.dot -o testgraph.dot.png contains this:

dot - graphviz version 8.1.0 (20230707.2238)
libdir = "/DATA/hyer/src/conda/miniconda3_cal/envs/graphviz/bin/../lib/graphviz"
Activated plugin library: libgvplugin_dot_layout.so.6
Using layout: dot:dot_layout
Using render: cairo:cairo
Using device: png:cairo:cairo
The plugin configuration file:
        /DATA/hyer/src/conda/miniconda3_cal/envs/graphviz/bin/../lib/graphviz/config6
                was successfully loaded.
    render      :  cairo dot dot_json fig gd json json0 map mp pic pov ps svg tk vrml xdot xdot_json
    layout      :  circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
    textlayout  :  textlayout
    device      :  bmp canon cmap cmapx cmapx_np dot dot_json eps fig gd gd2 gif gv ico imap imap_np ismap jpe jpeg jpg json json0 mp pdf pic plain plain-ext png pov ps ps2 svg svgz tif tiff tk vrml vt100 vt100-24bit wbmp webp xdot xdot1.2 xdot1.4 xdot_json
    loadimage   :  (lib) bmp eps gd gd2 gif ico jpe jpeg jpg png ps svg webp xbm
pack info:
  mode   undefined
  size   0
  flags  0
  margin 8
pack info:
  mode   node
  size   0
  flags  0
fontname: "Times-Roman" resolved to: (ps:pango  Serif,  REGULAR) (PangoCairoFcFont) "Inconsolata, Regular" /DATA/hyer/src/conda/miniconda3_cal/envs/graphviz/fonts/Inconsolata-Regular.ttf
network simplex:  1 nodes 0 edges maxiter=2147483647 balance=1
network simplex: 1 nodes 0 edges 0 iter 0.00 sec
network simplex:  2 nodes 1 edges maxiter=2147483647 balance=1
network simplex: 2 nodes 1 edges 0 iter 0.00 sec
Maxrank = 1, minrank = 0
mincross: pass 0 iter 0 trying 0 cur_cross 0 best_cross 0
mincross: pass 0 iter 0 trying 0 cur_cross 0 best_cross 0
mincross TEST: 0 crossings, 0.00 secs.
network simplex:  4 nodes 3 edges maxiter=2147483647 balance=2
network simplex: 4 nodes 3 edges 0 iter 0.00 sec
routesplines: 1 edges, 3 boxes 0.00 sec
Using render: cairo:cairo
Using device: png:cairo:cairo
dot: allocating a 182K cairo image surface (301 x 155 pixels)
gvRenderJobs TEST: 0.01 secs.

You need square brackets [ ], not braces { } to enclose attributes. I.e. blackrect[fontsize=21.0, fontname="Bookman-LightItalic", .... I’m surprised your graph passes through Graphviz warning-free.

1 Like

Nice catch!!

Here is what Graphviz sees (dot -Tcanon) . New subgraphs because of the braces and attributes at the graph-level.

digraph TEST {
	node [label="\N",
		shape=ellipse,
		style=solid
	];
	edge [style=solid];
	{
		graph [fontcolor=black,
			fontname="Bookman-LightItalic",
			fontsize=21.0,
			shape=rectangle,
			style=solid
		];
	}
	{
		graph [fontcolor=blue,
			fontname=Monospace,
			fontsize=27.75,
			shape=ellipse,
			style=solid
		];
	}
	{
		graph [fontcolor=green,
			fontname=serif,
			fontsize=8.25,
			shape=ellipse,
			style=solid
		];
	}
	{
		graph [color=red,
			fontcolor=black,
			fontname="Inconsolata:style=Regular",
			fontsize=10.75,
			style=solid
		];
	}
	blackrect;
	bigblue -> smallgreen;
}

Thanks to all for the assist. Summary and postscript: The syntax I was using was wildly wrong, it’s amazing that graphviz was able to parse it. With this updated syntax:

digraph "TEST" {
    node [shape = ellipse, style = solid]
    edge [style = solid]
    blackrect [fontsize = 21.0, fontname = "Bookman-LightItalic", fontcolor = black, shape = rectangle, style = solid]        
    bigblue [fontsize = 27.75, fontname = "Monospace", fontcolor = "blue", shape = ellipse, style = solid]
    smallgreen [fontsize = 8.25, fontname = "serif", fontcolor = "green", shape = ellipse, style = solid]
    bigblue -> smallgreen [fontsize = 10.75, fontname = "Inconsolata:style=Regular", fontcolor = black, color = "red", style = solid, label="Connector"]
}

I get the response I was hoping for:
image