1

I'm displaying a diagram with graphviz and need emoji to display but I constantly get display errors as shown here:

as shown here

in this case should be (1 )

My understanding from graphviz font path attribute and dot guide pdf quoted below, I should be able to change the fontpath to load an emoji capable font like NotoColorEmoji.

For bitmap output, such as GIF or JPG, dot relies on having these fonts available during layout. Most precompiled installations of Graphviz use the fontconfig library for matching font names to available fontfiles. fontconfig comes with a set of utilities for showing matches and installing fonts. Please refer to the fontconfig documentation, or the external Graphviz FontFAQ or for further details. If Graphviz is built without fontconfig (which usually means you compiled it from source code on your own), the fontpath attribute can specify a list of directories3 which should be searched for the font files. If this is not set, dot will use the DOTFONTPATH environment variable or, if this is not set, the GDFONTPATH environment variable. If none of these is set, dot uses a built-in list.

The only information I can find on changing the fontpath is from a 10 year old question and dead links on graphviz.org.

At the moment I'm testing in repl.it so it's possible the path isn't jiving somehow. End goal is to update my current docker image somehow with the font file. So far it seems I haven't been successful in loading the font at all and I still have no guarantee it will display emoji. I'm open to other suggestions to display emoji (hopefully with graphviz).

digraph tree {
    fontpath="/"
    "foo" [label="bar", shape=triangle, color=black fillcolor=peru, style=filled, fontname="NotoColorEmojis"]
  • what OS? what output format? fontpath="/" is probably incorrect (unless fonts are in /) where is this fontfile located? – sroush Dec 13 '21 at 16:32
  • a web search says that this may be a fontconfig issue (not Graphviz). add a "-v" to the command line (dot -v -T...). What does it say about resolving the fontname? – sroush Dec 14 '21 at 03:11
  • @sroush repl.it uses some form of linux. The docker file will be running ubuntu. The font file is just located in the root of the repl.it folder so it's my best guess. – Alex Cooper Dec 20 '21 at 08:23
  • 1
    @sroush -v -T just says 'Missing argument for -T flag' – Alex Cooper Dec 20 '21 at 08:24
  • I should have said: "add -v " to your existing command line. Should it be NotoColorEmoji", not "NotoColorEmojis"? (no final s) Maybe this will help: https://gist.github.com/TheBunnyMan123/d8f5c08a5353bc28524596830c221c59 – sroush Dec 21 '21 at 20:14
  • I don't know what your intended method of deployment is, but if you can, I would recommend using the command line flags. Those have worked for me while putting the `fontname` attribute in the `.dot` file has not. This other SO answer has more detail: https://stackoverflow.com/a/42973828/3025557 – nimble_ninja Mar 26 '22 at 17:27

0 Answers0