Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 158cf33

Browse filesBrowse files
committed
Merge pull request #1604 from dmcdougall/fix_badfonts
Make font_manager ignore KeyErrors for bad fonts
2 parents 07fa831 + f6e086b commit 158cf33
Copy full SHA for 158cf33

File tree

Expand file treeCollapse file tree

1 file changed

+8
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-2
lines changed

‎lib/matplotlib/font_manager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/font_manager.py
+8-2Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.