When both the ps.useafm and axes.unicode_minus rcparams are set, the use of a unicode minus e.g. in a tick label causes an exception to bubble out.
rcdefaults()
rcParams["ps.useafm"] = True
rcParams["axes.formatter.use_mathtext"] = True
xlim(-1, 1)
savefig("/tmp/test.ps")
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 1167, in _get_info
symbol_name = font.get_name_char(glyph)
File "/usr/lib/python3.6/site-packages/matplotlib/afm.py", line 456, in get_name_char
wx, name, bbox = self._metrics[c]
KeyError: 8722
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.6/site-packages/matplotlib/pyplot.py", line 697, in savefig
res = fig.savefig(*args, **kwargs)
<elided, long pyparsing traceback>
File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 2643, in symbol
char = Char(c, self.get_state())
File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 1470, in __init__
self._update_metrics()
File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 1477, in _update_metrics
self.font, self.font_class, self.c, self.fontsize, self.dpi, self.math)
File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 475, in get_metrics
info = self._get_info(font, font_class, sym, fontsize, dpi, math)
File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 1170, in _get_info
(font.postscript_name, sym),
AttributeError: 'AFM' object has no attribute 'postscript_name'
Not an exception, or possibly at least a clearer error. (It may well be the case that the issue is fundamentally unfixable, depending on how AFM fonts work (I have no idea), but at least we shouldn't bubble an AttributeError out.)
Bug report
Bug summary
When both the ps.useafm and axes.unicode_minus rcparams are set, the use of a unicode minus e.g. in a tick label causes an exception to bubble out.
Code for reproduction
EDIT:
also reproduces the issue
Actual outcome
Expected outcome
Not an exception, or possibly at least a clearer error. (It may well be the case that the issue is fundamentally unfixable, depending on how AFM fonts work (I have no idea), but at least we shouldn't bubble an AttributeError out.)
Matplotlib version