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

Skip to content

Commit 5fe2e5d

Browse files
committed
Make lack of support more explicit for non-postscript fonts + usetex.
The info-level log can easily be hidden, and the KeyError may look like a bug on Matplotlib's side. Instead, explicitly raise an exception whose error message states that Matplotlib doesn't currently support certain cases. Use a LookupError (a parent class of KeyError, so a slight API break) rather than a KeyError as KeyError formats its argument as if it was the missing key (calling repr on it), which would not be the case here.
1 parent 3a265b3 commit 5fe2e5d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``dviread.PsfontsMap`` now raises LookupError instead of KeyError for missing fonts
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lib/matplotlib/dviread.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import struct
2828
import subprocess
2929
import sys
30-
import textwrap
3130

3231
import numpy as np
3332

@@ -852,14 +851,12 @@ def __getitem__(self, texname):
852851
try:
853852
return self._parsed[texname]
854853
except KeyError:
855-
fmt = ('An associated PostScript font (required by Matplotlib) '
856-
'could not be found for TeX font {0!r} in {1!r}. This '
857-
'problem can often be solved by installing a suitable '
858-
'PostScript font package in your TeX package manager.')
859-
_log.info(textwrap.fill(
860-
fmt.format(texname.decode('ascii'), self._filename),
861-
break_on_hyphens=False, break_long_words=False))
862-
raise
854+
raise LookupError(
855+
f"An associated PostScript font (required by Matplotlib) "
856+
f"could not be found for TeX font {texname.decode('ascii')!r} "
857+
f"in {self._filename!r}; this problem can often be solved by "
858+
f"installing a suitable PostScript font package in your TeX "
859+
f"package manager") from None
863860

864861
def _parse_and_cache_line(self, line):
865862
"""

0 commit comments

Comments
 (0)