Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0877fd7

Browse files
Merge pull request #20474 from anntzer/psfontsmaperror
Make lack of support more explicit for non-postscript fonts + usetex.
2 parents f230dfb + a3af1d8 commit 0877fd7

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
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
"""

‎lib/matplotlib/tests/test_dviread.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def test_PsfontsMap(monkeypatch):
5454
entry = fontmap[b'TeXfontC']
5555
assert entry.psname == b'PSfontC3'
5656
# Missing font
57-
with pytest.raises(KeyError, match='no-such-font'):
57+
with pytest.raises(LookupError, match='no-such-font'):
5858
fontmap[b'no-such-font']
59-
with pytest.raises(KeyError, match='%'):
59+
with pytest.raises(LookupError, match='%'):
6060
fontmap[b'%']
6161

6262

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /