Is there a way to add a background to edge labels? I tried fillcolor but it only colors the arrow, and the edge labels kept having a transparent background.
You can use an “HTML” label (Node Shapes | Graphviz)
graph C {
y--z [label=<<table bgcolor="orange" border="0" cellspacing="0"><tr><td>table text</td></tr></table>>]
}
Giving:
Is there a bug with that? A long edge label overflows the background
digraph g1 {
a->b [label=<<table bgcolor="orange" border="0" cellspacing="0"><tr><td>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td></tr></table>>];
}
[dot]
digraph g1 {
a->b [label=<<table bgcolor=“orange” border=“0” cellspacing=“0”><tr><td>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td></tr></table>>];
}
[/dot]
Result on Graphviz Visual Editor
Looks fine on my Linux system.
- What OS are you using?
- What output format? (if SVG, see: Font FAQ | Graphviz and Unwanted space around html font tags with svg output (#1891) · Issues · graphviz / graphviz · GitLab)
File a bug report here: Work items · graphviz / graphviz · GitLab
I’m stuck filing a bug report. The Create Issue button loads forever:
I tried signing up to GitLab but it seems it doesn’t support my region anymore[1]. It said will redirect me to JiHu but the landing page is 404. What the heck
Could someone file the bug report for me?
- Graphviz 15.0.0 (20260523.1842) (from 64-bit ZIP archive)
- Windows 11
- Only SVG has the problem
- Tried How can I tell what fonts are available?, but
fc-listcommand is not found.
I remember seeing this in news 2 years ago ↩︎
Sorry about the problem. This has been discussed and explained enough times already. The issue is, “Graphviz generates host-dependent SVG.” It can manifest itself in various ways, e.g. “text label is clipped” “text label overflows into another object” “text label background is incorrect” but they are all the same thing.
Ways we may approach this:
- Don’t change anything, just continue to explain/ignore.
- Deprecate/remove the native SVG driver in favor of cairopango, which does its own font embedding to avoid this issue.
- Program a font embedding feature like that of the cairopango driver into the native SVG driver, unfortunately giving up some of its simplicity and “efficiency.”
- Figure out and program a way to display a warning when host-dependent SVG is moved to an incompatible host. Not sure this can be done without Javascript or other executable semantics that may be incompatible with the way the native SVG output is probably being used, so this may not even do any good.
- the command
dot -Tsvg:cairo ...(as documented in the font FAQ and mentioned by Stephen) will produce output you desire - the reference to fc-list in the font FAQ does not apply to Windows (only Linux & maybe Macos). I will create a documentation Issue (bug report).
- the Windows command “settings > personalization > fonts” seems to list installed fonts.
- the existing Issue Unwanted space around html font tags with svg output (#1891) · Issues · graphviz / graphviz · GitLab now also links to this page
- another possible improvement / approach (in addition to Stephen’s list) is to add SVG’s (relatively new) @face-font feature (see Unwanted space around html font tags with svg output (#1891) · Issues · graphviz / graphviz · GitLab)
- font problems are a pain in the butt
[bullet #1 has been edited to be -Tsvg:cairo ... ]
If there’s an issue to be filed, I can happily do this. But I don’t think it would gain us much as you presumably could not get notifications about updates to it there. You’ve got the attention of the main Graphviz developers on the forum here already.
You’re assuming hsambirchaaaaaaaaa generated the graph on one machine and is viewing it on another? I guess that could be the cause, but I don’t see anything in their previous replies that suggests they’re doing this.
You mean dot -Tsvg:cairo …?
You’re right, I have no basis to say the SVG was generated on one machine and viewed in another.
It’s better to say, “Graphviz generates host / renderer dependent SVG.” For example on a given machine, Graphviz might use system fonts while other programs (like Chrome, Microsoft Office, Inkscape, and Adobe Illustrator) might each have their own additional fonts.
Thanks, I have edited my typo to be -Tsvg:cairo ...
As @mattr suggested, -Tsvg (not using cairo) on my Windows system, also produces the bug.





