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

Skip to content

Commit a165735

Browse files
committed
Merge pull request #4521 from jkseppan/issue-4475
ENH: Raise more useful error when tfm file is missing
2 parents fdf1bb5 + d7edc1c commit a165735

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/matplotlib/dviread.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,18 @@ def _xxx(self, special):
395395
'debug')
396396

397397
def _fnt_def(self, k, c, s, d, a, l, n):
398-
tfm = _tfmfile(n[-l:].decode('ascii'))
398+
fontname = n[-l:].decode('ascii')
399+
tfm = _tfmfile(fontname)
400+
if tfm is None:
401+
raise FileNotFoundError("missing font metrics file: %s" % fontname)
399402
if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
400403
raise ValueError('tfm checksum mismatch: %s'%n)
401404
# It seems that the assumption behind the following check is incorrect:
402405
#if d != tfm.design_size:
403406
# raise ValueError, 'tfm design size mismatch: %d in dvi, %d in %s'%\
404407
# (d, tfm.design_size, n)
405408

406-
vf = _vffile(n[-l:].decode('ascii'))
409+
vf = _vffile(fontname)
407410

408411
self.fonts[k] = DviFont(scale=s, tfm=tfm, texname=n, vf=vf)
409412

0 commit comments

Comments
 (0)