From ac216a086e2999ab5b4b07728de2e7516bd7cb61 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 8 Jan 2018 00:32:24 -0800 Subject: [PATCH] AFM fonts don't have .postscript_name, but .get_fontname(). ``` rcdefaults() rcParams["ps.useafm"] = True rcParams["axes.formatter.use_mathtext"] = True xlim(-1, 1) savefig("/tmp/test.ps") ``` would result in a crash when trying to format a warning because AFM fonts (which are the only ones used by the StandardPSFonts class (see constructor and _get_class) don't have a postscript_name attribute; the corresponding method is get_fontname(). --- lib/matplotlib/mathtext.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/mathtext.py b/lib/matplotlib/mathtext.py index a9f0aa3c61e9..2ccfd6c2c064 100644 --- a/lib/matplotlib/mathtext.py +++ b/lib/matplotlib/mathtext.py @@ -1146,7 +1146,7 @@ def _get_info (self, fontname, font_class, sym, fontsize, dpi, math=True): num = ord(glyph) found_symbol = True else: - warn("No TeX to built-in Postscript mapping for '%s'" % sym, + warn("No TeX to built-in Postscript mapping for {!r}".format(sym), MathTextWarning) slanted = (fontname == 'it') @@ -1156,9 +1156,8 @@ def _get_info (self, fontname, font_class, sym, fontsize, dpi, math=True): try: symbol_name = font.get_name_char(glyph) except KeyError: - warn("No glyph in standard Postscript font '%s' for '%s'" % - (font.postscript_name, sym), - MathTextWarning) + warn("No glyph in standard Postscript font {!r} for {!r}" + .format(font.get_fontname(), sym), MathTextWarning) found_symbol = False if not found_symbol: