I'm looking for some guidance on using system-installed truetype fonts with matplotlib. I asked this question on the matplotlib mailing list, but it didn't garner any responses. Here's what I've found so far, using the PDF backend in matplotlib 0.91.2 on 10.5/leopard's native python 2.5 (installed using easy_install).

Matplotlib itself is working well and with matplotlib.font_manager.OSXInstalledFonts() I can see that it seems to know what fonts I have on my system. I can even get it to find some of these fonts. However any attempts to use them results in errors when writing out the figure (I've included some stack traces below).

Are there reasons to think another backend would work if PDF fails? Also, I'd be interested in an easy way to take a given font file and figure out whether it is of a type supported by MPL and what name I should give to MPL to find and use it.

Nick Matsakis

------ an error using /Library/Fonts/tahoma.ttf
Traceback (most recent call last):
  ...skipping some calls...
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backend_bases.py",
line 1195, in print_figure
     **kwargs)
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backends/backend_pdf.py", line 1969, in print_pdf
     file.close()
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backends/backend_pdf.py", line 420, in close
     self.writeFonts()
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backends/backend_pdf.py", line 490, in writeFonts
     fontdictObject = self.embedTTF(realpath, chars[1])
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backends/backend_pdf.py", line 859, in embedTTF
     ps_name = Name(font.get_sfnt()[(1,0,0,6)])
KeyError: (1, 0, 0, 6)

----- a different error using /System/Library/Fonts/AppleGothic.ttf
   ...skipping some calls...
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backend_bases.py", line 1195, in print_figure
     **kwargs)
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backends/backend_pdf.py", line 1969, in print_pdf
     file.close()
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backends/backend_pdf.py", line 420, in close
     self.writeFonts()
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backends/backend_pdf.py", line 490, in writeFonts
     fontdictObject = self.embedTTF(realpath, chars[1])
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backends/backend_pdf.py", line 901, in embedTTF
     return embedTTFType3(font, characters, descriptor)
   File
"/Library/Python/2.5/site-packages/matplotlib-0.91.2-py2.5-macosx-10.5-ppc.e
gg/matplotlib/backends/backend_pdf.py", line 689, in embedTTFType3
     glyph_name = font.get_glyph_name(gind)
RuntimeError: Face has no glyph names
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to