It appears the Times-Roman font found by fontconfig does not have emojis. You could verify this by fc-match -v Times-Roman to find the file, and use some other program to view it. There is also a simple command line tool (somewhere) to render UTF-8 via pango but I don’t remember what it is any more; you’d have to search for it. I think you can make a personal fonts.conf file to control fontconfig bindings.
It might be easier to set the graph, node, and edge fontname in the graphviz file to a different font that has emojis. I’m not sure what font that would be. (Obviously you already have one somewhere.)
There’s no way to globally change the default graph, node, and edge label fonts in Graphviz with one setting, unfortunately. This would be a nice minor enhancement.
Sometimes we have characters that doesn’t work with a single font, as encoding is utf-8 by default, it was better to handle this stuff automatically by library.
import os
import unicodedata
from fontTools.ttLib import TTFont
def get_windows_fonts():
windows_fonts = []
windows_font_directories = [
os.path.join(os.environ.get('SystemRoot', 'C:\\Windows'), 'Fonts')
]
for font_dir in windows_font_directories:
if os.path.exists(font_dir):
for root, dirs, files in os.walk(font_dir):
for file in files:
if file.lower().endswith(".ttf"):
windows_fonts.append(os.path.join(root, file))
return windows_fonts
def char_in_font(unicode_char, font):
try:
for cmap in font['cmap'].tables:
if cmap.isUnicode():
if ord(unicode_char) in cmap.cmap:
return True
except AssertionError as e:
pass
return False
def test(char):
windows_fonts = get_windows_fonts()
for font_path in windows_fonts:
font = TTFont(font_path)
if char_in_font(char, font):
print(f"{char} {unicodedata.name(char)} in {font_path}")
characters = '@ঔৣ☬✞𝔚𝔥𝔞𝔱𝔢𝔳𝔢𝔯✞☬ঔৣ'
for char in characters:
test(char)