Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d509a90

Browse files
committed
Log the name of unsupported fonts
FT2Font throws RuntimeError for some fonts
1 parent 702eb40 commit d509a90

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lib/matplotlib/backends/_backend_pdf_ps.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from io import BytesIO
66
import functools
7+
import logging
78

89
from fontTools import subset
910

@@ -168,7 +169,13 @@ def _get_font_afm(self, prop):
168169

169170
def _get_font_ttf(self, prop):
170171
fname = font_manager.findfont(prop)
171-
font = font_manager.get_font(fname)
172-
font.clear()
173-
font.set_size(prop.get_size_in_points(), 72)
174-
return font
172+
try:
173+
font = font_manager.get_font(fname)
174+
font.clear()
175+
font.set_size(prop.get_size_in_points(), 72)
176+
return font
177+
except RuntimeError:
178+
logging.getLogger(__name__).warning(
179+
"The PostScript/PDF backend does not currently "
180+
"support the selected font (%s).", fname)
181+
raise

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def _font_to_ps_type42(font_path, chars, fh):
234234
except RuntimeError:
235235
_log.warning(
236236
"The PostScript backend does not currently "
237-
"support the selected font.")
237+
"support the selected font (%s).", font_path)
238238
raise
239239

240240

0 commit comments

Comments
 (0)