I’m trying to access macos fonts and the only way I’ve been able to is by outputting to pdf:quartz. Unfortunately, node label centering seems to be off. Here is a minimal reproducible example,
And I am rendering with dot -Tpdf:quartz <GRAPH>.dot -o <GRAPH>.pdf. I’ve uploaded the output I get with dot - graphviz version 12.2.1 (20241206.2353).
Weird. Not all MacOS system fonts have this problem. For example, Luminari looks ok. “Apple Chancery” looks centered but the baseline is too low. The verbose messages are odd:
fontname: "Hoefler Text" resolved to: (PangoCairoCoreTextFont) "Hoefler Text 14"
fontname: "Luminari" resolved to: (PangoCairoCoreTextFont) "Luminari 14"
fontname: "Apple Chancery" resolved to: (PangoCairoCoreTextFont) "Helvetica 14"
Why PangoCairoCoreTextFont when we thought we were in the world of Quartz?
Why substitute “Helvetica” for “Apple Chancery” and then the final rendering is a script font after all?
I don’t want to raise anyone’s hopes – the author of this code, I believe Glen Low, hasn’t been in touch for over 4 years, and I don’t know who else would be willing and able to dig in.
This is a bit off-topic, but I discovered while working on CMake: fix 'pango_fc_font_lock_face' discovery (8a67bf0d) · Commits · graphviz / graphviz · GitLab that we seem to be gradually losing the ability to debug font selection problems. This isn’t anything changing on the Graphviz side but rather font library APIs evolving into more of a “I’ll handle this, don’t worry your pretty little head about fonts” vibe. Fonts and text rendering are surprisingly complex domains, so perhaps the authors of these libraries have the right approach. But it does mean that when things go wrong, our ability to inspect what is happening is limited.
That’s a good observation. The graphviz pangocairo renderer at least in Linux relies on fontconfig, very much in the spirit of what you described. Some of its inner workings are described in the fonts-conf documentation under “Font Matching”. At some point when we were working on this, we tried to come up with an easy way to be able to issue helpful warnings like, “You requested Steve’s 2024 Cursive Handwriting Font, but unfortunately we can only give you Courier” but the APIs are not engineered to do that.
I don’t remember how graphviz font names are resolved in macOS core graphics (quartz) and in Windows, and I’m still not sure even after looking at the code for a minute or two, but it may be the case that all roads go through fontconfig.