8000 Parse {lua,xe}tex-generated dvi in dviread. · matplotlib/matplotlib@2749bac · GitHub
[go: up one dir, main page]

Skip to content

Commit 2749bac

Browse files
committed
Parse {lua,xe}tex-generated dvi in dviread.
1 parent a3c14cf commit 2749bac

File tree

9 files changed

+1436
-110
lines changed

9 files changed

+1436
-110
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -991,11 +991,11 @@ def _embedTeXFont(self, fontinfo):
991991

992992
# Widths
993993
widthsObject = self.reserveObject('font widths')
994-
tfm = fontinfo.dvifont._tfm
994+
font_metrics = fontinfo.dvifont._metrics
995995
# convert from TeX's 12.20 representation to 1/1000 text space units.
996-
widths = [(1000 * metrics.tex_width) >> 20
997-
if (metrics := tfm.get_metrics(char)) else 0
998-
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)]
999999
self.writeObject(widthsObject, widths)
10001000

10011001
# Font dictionary

lib/matplotlib/dviread.py

Lines changed: 212 additions & 86 deletions
Large diffs are not rendered by default.

lib/matplotlib/dviread.pyi

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,27 @@ class Dvi:
5858

5959
class DviFont:
6060
texname: bytes
61-
size: float
6261
def __init__(
63-
self, scale: float, tfm: Tfm, texname: bytes, vf: Vf | None
62+
self, scale: float, metrics: Tfm | TtfMetrics, texname: bytes, vf: Vf | None
6463
) -> None: ...
64+
@classmethod
65+
def from_luatex(cls, scale: float, texname: bytes): ...
66+
@classmethod
67+
def from_xetex(
68+
cls, scale: float, texname: bytes, subfont: int, effects: dict[str, float]
69+
): ...
6570
def __eq__(self, other: object) -> bool: ...
6671
def __ne__(self, other: object) -> bool: ...
6772
@property
73+
def size(self) -> float: ...
74+
@property
6875
def widths(self) -> list[int]: ...
76+
@property
77+
def path(self) -> Path: ...
78+
@property
79+
def subfont(self) -> int: ...
80+
@property
81+
def effects(self) -> dict[str, float]: ...
6982

7083
class Vf(Dvi):
7184
def __init__(self, filename: str | os.PathLike) -> None: ...
@@ -91,6 +104,10 @@ class Tfm:
91104
@property
92105
def depth(self) -> dict[int, int]: ...
93106

107+
class TtfMetrics:
108+
def __init__(self, filename: str | os.PathLike) -> None: ...
109+
def get_metrics(self, idx: int) -> TexMetrics: ...
110+
94111
class PsFont(NamedTuple):
95112
texname: bytes
96113
psname: bytes

0 commit comments

Comments
 (0)
0