From b8af401e76dba16afd8bf02f7c4f0b093ace11ce Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 11 Nov 2019 21:57:36 +0100 Subject: [PATCH] Rely on findfont autofallback-to-default in pdf/ps backends. findfont(...) will never return None unless fallback_to_default=False is passed -- the default is True and causes afm searches to fall back to Helvetica -- so the "filename is None" branch never occurs. (The code in the pdf/ps backends came in in af9954d (2009) whereas fallback_to_default only came in in 94120dc (2010).) --- lib/matplotlib/backends/_backend_pdf_ps.py | 7 ++----- lib/matplotlib/backends/backend_pdf.py | 4 ---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/matplotlib/backends/_backend_pdf_ps.py b/lib/matplotlib/backends/_backend_pdf_ps.py index e806cddd6985..bd06c39028bd 100644 --- a/lib/matplotlib/backends/_backend_pdf_ps.py +++ b/lib/matplotlib/backends/_backend_pdf_ps.py @@ -69,11 +69,8 @@ def get_text_width_height_descent(self, s, prop, ismath): return w, h, d def _get_font_afm(self, prop): - fname = ( - font_manager.findfont( - prop, fontext="afm", directory=self._afm_font_dir) - or font_manager.findfont( - "Helvetica", fontext="afm", directory=self._afm_font_dir)) + fname = font_manager.findfont( + prop, fontext="afm", directory=self._afm_font_dir) return _cached_get_afm_from_fname(fname) def _get_font_ttf(self, prop): diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py index 1c9a85449f83..d6de9202199f 100644 --- a/lib/matplotlib/backends/backend_pdf.py +++ b/lib/matplotlib/backends/backend_pdf.py @@ -663,10 +663,6 @@ def fontName(self, fontprop): elif rcParams['pdf.use14corefonts']: filename = findfont( fontprop, fontext='afm', directory=RendererPdf._afm_font_dir) - if filename is None: - filename = findfont( - "Helvetica", - fontext='afm', directory=RendererPdf._afm_font_dir) else: filename = findfont(fontprop)