Skip to content

Commit 86f4a4e

Browse files
authored
Merge pull request matplotlib#6715 from tacaswell/fix_bad_ttf
Fix bad ttf
2 parents 9f9e8a3 + 6828691 commit 86f4a4e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/matplotlib/font_manager.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,10 @@ def createFontList(fontfiles, fontext='ttf'):
562562
for fpath in fontfiles:
563563
verbose.report('createFontDict: %s' % (fpath), 'debug')
564564
fname = os.path.split(fpath)[1]
565-
if fname in seen: continue
566-
else: seen[fname] = 1
565+
if fname in seen:
566+
continue
567+
else:
568+
seen[fname] = 1
567569
if fontext == 'afm':
568570
try:
569571
fh = open(fpath, 'rb')
@@ -576,7 +578,7 @@ def createFontList(fontfiles, fontext='ttf'):
576578
finally:
577579
fh.close()
578580
except RuntimeError:
579-
verbose.report("Could not parse font file %s"%fpath)
581+
verbose.report("Could not parse font file %s" % fpath)
580582
continue
581583
try:
582584
prop = afmFontProperty(fpath, font)
@@ -586,20 +588,21 @@ def createFontList(fontfiles, fontext='ttf'):
586588
try:
587589
font = ft2font.FT2Font(fpath)
588590
except RuntimeError:
589-
verbose.report("Could not open font file %s"%fpath)
591+
verbose.report("Could not open font file %s" % fpath)
590592
continue
591593
except UnicodeError:
592594
verbose.report("Cannot handle unicode filenames")
593-
#print >> sys.stderr, 'Bad file is', fpath
595+
# print >> sys.stderr, 'Bad file is', fpath
594596
continue
595597
try:
596598
prop = ttfFontProperty(font)
597-
except (KeyError, RuntimeError):
599+
except (KeyError, RuntimeError, ValueError):
598600
continue
599601

600602
fontlist.append(prop)
601603
return fontlist
602604

605+
603606
class FontProperties(object):
604607
"""
605608
A class for storing and manipulating font properties.

0 commit comments

Comments
 (0)