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

Skip to content

Commit b8af401

Browse files
committed
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).)
1 parent fc413b3 commit b8af401

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

lib/matplotlib/backends/_backend_pdf_ps.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,8 @@ def get_text_width_height_descent(self, s, prop, ismath):
6969
return w, h, d
7070

7171
def _get_font_afm(self, prop):
72-
fname = (
73-
font_manager.findfont(
74-
prop, fontext="afm", directory=self._afm_font_dir)
75-
or font_manager.findfont(
76-
"Helvetica", fontext="afm", directory=self._afm_font_dir))
72+
fname = font_manager.findfont(
73+
prop, fontext="afm", directory=self._afm_font_dir)
7774
return _cached_get_afm_from_fname(fname)
7875

7976
def _get_font_ttf(self, prop):

lib/matplotlib/backends/backend_pdf.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -663,10 +663,6 @@ def fontName(self, fontprop):
663663
elif rcParams['pdf.use14corefonts']:
664664
filename = findfont(
665665
fontprop, fontext='afm', directory=RendererPdf._afm_font_dir)
666-
if filename is None:
667-
filename = findfont(
668-
"Helvetica",
669-
fontext='afm', directory=RendererPdf._afm_font_dir)
670666
else:
671667
filename = findfont(fontprop)
672668

0 commit comments

Comments
 (0)