Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Log the name of unsupported fonts
FT2Font throws RuntimeError for some fonts
  • Loading branch information
jkseppan authored and QuLogic committed Oct 16, 2024
commit 94698fa16388df088ce7ecd841eb9858afaf97ed
15 changes: 11 additions & 4 deletions lib/matplotlib/backends/_backend_pdf_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from io import BytesIO
import functools
import logging

from fontTools import subset

Expand Down Expand Up @@ -177,7 +178,13 @@ def _get_font_afm(self, prop):

def _get_font_ttf(self, prop):
fnames = font_manager.fontManager._find_fonts_by_props(prop)
font = font_manager.get_font(fnames)
font.clear()
font.set_size(prop.get_size_in_points(), 72)
return font
try:
font = font_manager.get_font(fnames)
font.clear()
font.set_size(prop.get_size_in_points(), 72)
return font
except RuntimeError:
logging.getLogger(__name__).warning(
"The PostScript/PDF backend does not currently "
"support the selected font (%s).", fnames)
raise
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _font_to_ps_type42(font_path, chars, fh):
except RuntimeError:
_log.warning(
"The PostScript backend does not currently "
"support the selected font.")
"support the selected font (%s).", font_path)
raise


Expand Down