Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,11 +1035,10 @@ def _embedTeXFont(self, dvifont):
fontdict['Encoding'] = self._generate_encoding(encoding)
fc = fontdict['FirstChar'] = min(encoding.keys(), default=0)
lc = fontdict['LastChar'] = max(encoding.keys(), default=255)

# Convert glyph widths from TeX 12.20 fixed point to 1/1000 text space units
tfm = dvifont._tfm
widths = [(1000 * metrics.tex_width) >> 20
if (metrics := tfm.get_metrics(char)) else 0
font_metrics = dvifont._metrics
widths = [(1000 * glyph_metrics.tex_width) >> 20
if (glyph_metrics := font_metrics.get_metrics(char)) else 0
for char in range(fc, lc + 1)]
fontdict['Widths'] = widthsObject = self.reserveObject('glyph widths')
self.writeObject(widthsObject, widths)
Expand Down
10 changes: 7 additions & 3 deletions lib/matplotlib/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,20 @@ class _ExceptionInfo:
users and result in incorrect tracebacks.
"""

def __init__(self, cls, *args):
def __init__(self, cls, *args, notes=None):
self._cls = cls
self._args = args
self._notes = notes if notes is not None else []

@classmethod
def from_exception(cls, exc):
return cls(type(exc), *exc.args)
return cls(type(exc), *exc.args, notes=getattr(exc, "__notes__", []))

def to_exception(self):
return self._cls(*self._args)
exc = self._cls(*self._args)
for note in self._notes:
exc.add_note(note)
return exc


def _get_running_interactive_framework():
Expand Down
Loading
Loading