From 3a4d17c9d16a41275444d9b6c9810d8ac83636be Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 17 Mar 2019 21:02:49 -0700 Subject: [PATCH] Backport PR #13677: Log all failures to extract font properties. --- lib/matplotlib/font_manager.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 0f1e73513568..68136068b7f9 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -490,23 +490,25 @@ def createFontList(fontfiles, fontext='ttf'): continue try: prop = afmFontProperty(fpath, font) - except KeyError: + except KeyError as exc: + _log.info("Could not extract properties for %s: %s", + fpath, exc) continue else: try: font = ft2font.FT2Font(fpath) - except RuntimeError: - _log.info("Could not open font file %s", fpath) + except (OSError, RuntimeError) as exc: + _log.info("Could not open font file %s: %s", fpath, exc) continue except UnicodeError: _log.info("Cannot handle unicode filenames") continue - except OSError: - _log.info("IO error - cannot open font file %s", fpath) - continue try: prop = ttfFontProperty(font) - except (KeyError, RuntimeError, ValueError, NotImplementedError): + except (KeyError, RuntimeError, ValueError, + NotImplementedError) as exc: + _log.info("Could not extract properties for %s: %s", + fpath, exc) continue fontlist.append(prop)