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

Skip to content

Commit 8c70d76

Browse files
committed
Parse {lua,xe}tex-generated dvi in dviread.
1 parent 99a521b commit 8c70d76

File tree

12 files changed

+309
-217
lines changed

12 files changed

+309
-217
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -940,18 +940,13 @@ def dviFontName(self, dvifont):
940940

941941
tex_font_map = dviread.PsfontsMap(dviread.find_tex_file('pdftex.map'))
942942
psfont = tex_font_map[dvifont.texname]
943-
if psfont.filename is None:
944-
raise ValueError(
945-
"No usable font file found for {} (TeX: {}); "
946-
"the font may lack a Type-1 version"
947-
.format(psfont.psname, dvifont.texname))
948-
949943
pdfname = next(self._internal_font_seq)
950944
_log.debug('Assigning font %s = %s (dvi)', pdfname, dvifont.texname)
951945
self._dviFontInfo[dvifont.texname] = types.SimpleNamespace(
952946
dvifont=dvifont,
953947
pdfname=pdfname,
954-
fontfile=psfont.filename,
948+
# raises ValueError if psfont.filename is None.
949+
fontfile=str(dvifont.resolve_path()),
955950
basefont=psfont.psname,
956951
encodingfile=psfont.encoding,
957952
effects=psfont.effects)
@@ -996,11 +991,11 @@ def _embedTeXFont(self, fontinfo):
996991

997992
# Widths
998993
widthsObject = self.reserveObject('font widths')
999-
tfm = fontinfo.dvifont._tfm
994+
font_metrics = fontinfo.dvifont._metrics
1000995
# convert from TeX's 12.20 representation to 1/1000 text space units.
1001-
widths = [(1000 * metrics.tex_width) >> 20
1002-
if (metrics := tfm.get_metrics(char)) else 0
1003-
for char in range(max(tfm._glyph_metrics, default=-1) + 1)]
996+
widths = [(1000 * glyph_metrics.tex_width) >> 20
997+
if (glyph_metrics := font_metrics.get_metrics(char)) else 0
998+
for char in range(max(font_metrics._glyph_metrics, default=-1) + 1)]
1004999
self.writeObject(widthsObject, widths)
10051000

10061001
# Font dictionary

lib/matplotlib/cbook.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,20 @@ class _ExceptionInfo:
4343
users and result in incorrect tracebacks.
4444
"""
4545

46-
def __init__(self, cls, *args):
46+
def __init__(self, cls, *args, notes=None):
4747
self._cls = cls
4848
self._args = args
49+
self._notes = notes if notes is not None else []
4950

5051
@classmethod
5152
def from_exception(cls, exc):
52-
return cls(type(exc), *exc.args)
53+
return cls(type(exc), *exc.args, notes=getattr(exc, "__notes__", []))
5354

5455
def to_exception(self):
55-
return self._cls(*self._args)
56+
exc = self._cls(*self._args)
57+
for note in self._notes:
58+
exc.add_note(note)
59+
return exc
5660

5761

5862
def _get_running_interactive_framework():

0 commit comments

Comments
 (0)