diff --git a/lib/matplotlib/dviread.py b/lib/matplotlib/dviread.py index d6b085b2a831..8b4945eacb31 100644 --- a/lib/matplotlib/dviread.py +++ b/lib/matplotlib/dviread.py @@ -395,7 +395,10 @@ def _xxx(self, special): 'debug') def _fnt_def(self, k, c, s, d, a, l, n): - tfm = _tfmfile(n[-l:].decode('ascii')) + fontname = n[-l:].decode('ascii') + tfm = _tfmfile(fontname) + if tfm is None: + raise FileNotFoundError("missing font metrics file: %s" % fontname) if c != 0 and tfm.checksum != 0 and c != tfm.checksum: raise ValueError('tfm checksum mismatch: %s'%n) # It seems that the assumption behind the following check is incorrect: @@ -403,7 +406,7 @@ def _fnt_def(self, k, c, s, d, a, l, n): # raise ValueError, 'tfm design size mismatch: %d in dvi, %d in %s'%\ # (d, tfm.design_size, n) - vf = _vffile(n[-l:].decode('ascii')) + vf = _vffile(fontname) self.fonts[k] = DviFont(scale=s, tfm=tfm, texname=n, vf=vf)