I'm trying Pygments to convert some code into a highlighted image. Here's the Python script:
from pygments.lexers import PhpLexer
from pygments.formatters import ImageFormatter
from pygments.filters import CodeTagFilter
from pygments import highlight
code = open("myPhpCode.php").read()
formatter = ImageFormatter()
with open("myPhpCodeAsAnImage.png", "w+") as f:
f.write(highlight(code, PhpLexer(), formatter))
I've tried Python2 and Python3, on MacOs, I have also tried to set ImageFormatter's option "font_name="pathToFont" with the full path of a font I know exists, and I always get the following error :
pygments.formatters.img.FontNotFound: No usable fonts named: "Menlo"
Is there something I'm missing?