From: <jo...@us...> - 2008-12-31 19:57:00
|
Revision: 6728 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6728&view=rev Author: jouni Date: 2008-12-31 19:56:55 +0000 (Wed, 31 Dec 2008) Log Message: ----------- Don't crash with Microsoft fonts such as Tahoma Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-12-31 19:42:44 UTC (rev 6727) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-12-31 19:56:55 UTC (rev 6728) @@ -333,7 +333,7 @@ self.file.write(compressed) self.compressobj = None -class PdfFile: +class PdfFile(object): """PDF file with one page.""" def __init__(self, width, height, dpi, filename): @@ -900,7 +900,14 @@ # Beginning of main embedTTF function... # You are lost in a maze of TrueType tables, all different... - ps_name = Name(font.get_sfnt()[(1,0,0,6)]) + sfnt = font.get_sfnt() + try: + ps_name = sfnt[(1,0,0,6)] # Macintosh scheme + except KeyError: + # Microsoft scheme: + ps_name = sfnt[(3,1,0x0409,6)].decode('utf-16be').encode('ascii','replace') + # (see freetype/ttnameid.h) + ps_name = Name(ps_name) pclt = font.get_sfnt_table('pclt') \ or { 'capHeight': 0, 'xHeight': 0 } post = font.get_sfnt_table('post') \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |