Support (first font of) TTC files. by anntzer · Pull Request #9787 · matplotlib/matplotlib · GitHub
Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions .travis.yml
9 changes: 7 additions & 2 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,13 @@ def get_char_width(charcode):

# Make the charprocs array (using ttconv to generate the
# actual outlines)
rawcharprocs = ttconv.get_pdf_charprocs(
os.fsencode(filename), glyph_ids)
try:
rawcharprocs = ttconv.get_pdf_charprocs(
os.fsencode(filename), glyph_ids)
except RuntimeError:
_log.warning("The PDF backend does not currently support the "
"selected font.")
raise
charprocs = {}
for charname in sorted(rawcharprocs):
stream = rawcharprocs[charname]
Expand Down
10 changes: 8 additions & 2 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,14 @@ def print_figure_impl(fh):
"time; consider using the Cairo backend")
else:
fh.flush()
convert_ttf_to_ps(os.fsencode(font_filename),
fh, fonttype, glyph_ids)
try:
convert_ttf_to_ps(os.fsencode(font_filename),
fh, fonttype, glyph_ids)
except RuntimeError:
_log.warning("The PostScript backend does not "
"currently support the selected "
"font.")
raise
print("end", file=fh)
print("%%EndProlog", file=fh)

Expand Down
9 changes: 6 additions & 3 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,12 @@ def get_fontext_synonyms(fontext):
Return a list of file extensions extensions that are synonyms for
the given file extension *fileext*.
"""
return {'ttf': ('ttf', 'otf'),
'otf': ('ttf', 'otf'),
'afm': ('afm',)}[fontext]
return {
'afm': ['afm'],
'otf': ['otf', 'ttc', 'ttf'],
'ttc': ['otf', 'ttc', 'ttf'],
'ttf': ['otf', 'ttc', 'ttf'],
}[fontext]


def list_fonts(directory, extensions):
Expand Down
23 changes: 21 additions & 2 deletions lib/matplotlib/tests/test_font_manager.py