Skip to content

Commit

Permalink
Merge pull request #1604 from dmcdougall/fix_badfonts
Browse files Browse the repository at this point in the history
Make font_manager ignore KeyErrors for bad fonts
  • Loading branch information
mdboom committed Dec 17, 2012
2 parents 07fa831 + f6e086b commit 158cf33
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/matplotlib/font_manager.py
Expand Up @@ -565,7 +565,10 @@ def createFontList(fontfiles, fontext='ttf'):
except RuntimeError:
verbose.report("Could not parse font file %s"%fpath)
continue
prop = afmFontProperty(fpath, font)
try:
prop = afmFontProperty(fpath, font)
except KeyError:
continue
else:
try:
font = ft2font.FT2Font(str(fpath))
Expand All @@ -576,7 +579,10 @@ def createFontList(fontfiles, fontext='ttf'):
verbose.report("Cannot handle unicode filenames")
#print >> sys.stderr, 'Bad file is', fpath
continue
prop = ttfFontProperty(font)
try:
prop = ttfFontProperty(font)
except KeyError:
continue

fontlist.append(prop)
return fontlist
Expand Down

0 comments on commit 158cf33

Please sign in to comment.