Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 87e0ecf

Browse filesBrowse files
committed
Parse {lua,xe}tex-generated dvi in dviread.
1 parent 48be1ca commit 87e0ecf
Copy full SHA for 87e0ecf

File tree

9 files changed

+1435
-104
lines changed
Filter options

9 files changed

+1435
-104
lines changed

‎lib/matplotlib/backends/backend_pdf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pdf.py
+4-4Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/dviread.py
+211-80Lines changed: 211 additions & 80 deletions
Large diffs are not rendered by default.

‎lib/matplotlib/dviread.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/dviread.pyi
+19-2Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.