Skip to content

Fix bad ttf #6715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,10 @@ def createFontList(fontfiles, fontext='ttf'):
for fpath in fontfiles:
verbose.report('createFontDict: %s' % (fpath), 'debug')
fname = os.path.split(fpath)[1]
if fname in seen: continue
else: seen[fname] = 1
if fname in seen:
continue
else:
seen[fname] = 1
if fontext == 'afm':
try:
fh = open(fpath, 'rb')
Expand All @@ -576,7 +578,7 @@ def createFontList(fontfiles, fontext='ttf'):
finally:
fh.close()
except RuntimeError:
verbose.report("Could not parse font file %s"%fpath)
verbose.report("Could not parse font file %s" % fpath)
continue
try:
prop = afmFontProperty(fpath, font)
Expand All @@ -586,20 +588,21 @@ def createFontList(fontfiles, fontext='ttf'):
try:
font = ft2font.FT2Font(fpath)
except RuntimeError:
verbose.report("Could not open font file %s"%fpath)
verbose.report("Could not open font file %s" % fpath)
continue
except UnicodeError:
verbose.report("Cannot handle unicode filenames")
#print >> sys.stderr, 'Bad file is', fpath
# print >> sys.stderr, 'Bad file is', fpath
continue
try:
prop = ttfFontProperty(font)
except (KeyError, RuntimeError):
except (KeyError, RuntimeError, ValueError):
continue

fontlist.append(prop)
return fontlist


class FontProperties(object):
"""
A class for storing and manipulating font properties.
Expand Down