8000 Make font_manager ignore KeyErrors for bad fonts · madbouncer/matplotlib@f6e086b · GitHub
[go: up one dir, main page]

Skip to content

Commit f6e086b

Browse files
committed
Make font_manager ignore KeyErrors for bad fonts
1 parent da2d0c4 commit f6e086b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/font_manager.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,10 @@ def createFontList(fontfiles, fontext='ttf'):
565565
except RuntimeError:
566566
verbose.report("Could not parse font file %s"%fpath)
567567
continue
568-
prop = afmFontProperty(fpath, font)
568+
try:
569+
prop = afmFontProperty(fpath, font)
570+
except KeyError:
571+
continue
569572
else:
570573
try:
571574
font = ft2font.FT2Font(str(fpath))
@@ -576,7 +579,10 @@ def createFontList(fontfiles, fontext='ttf'):
576579
verbose.report("Cannot handle unicode filenames")
577580
#print >> sys.stderr, 'Bad file is', fpath
578581
continue
579-
prop = ttfFontProperty(font)
582+
try:
583+
prop = ttfFontProperty(font)
584+
except KeyError:
585+
continue
580586

581587
fontlist.append(prop)
582588
return fontlist

0 commit comments

Comments
 (0)
0