Skip to content

Commit 3fb9d07

Browse files
committed
Slightly improve output of dvi debug utilities, and tiny cleanups.
New output of `python -mmatplotlib.dviread /path/to/dvi` for `$\frac{1}{2}$`: ``` === new page === (w: 261235, h: 553676, d: 225994) font: 'cmr7' scale: 0.4375 x y glyph chr w (glyphs) 1061683 1183756 49 1 261235 1061683 1667786 50 2 261235 x y w h (boxes) 1061683 1291058 26213 261235 ``` old output: ``` === new page === font b'cmr7' scaled 0.4375 1061683 1183756 49 1 261235 1061683 1667786 50 2 261235 1061683 1291058 BOX 26213 261235 ```
1 parent f5880d2 commit 3fb9d07

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/matplotlib/dviread.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ def _output(self):
259259
for elt in self.text + self.boxes:
260260
if isinstance(elt, Box):
261261
x, y, h, w = elt
262-
e = 0 # zero depth
263-
else: # glyph
262+
e = 0 # zero depth
263+
else: # glyph
264264
x, y, font, g, w = elt
265265
h, e = font._height_depth_of(g)
266266
minx = min(minx, x)
@@ -1044,14 +1044,19 @@ def _fontfile(cls, suffix, texname):
10441044
with Dvi(args.filename, args.dpi) as dvi:
10451045
fontmap = PsfontsMap(find_tex_file('pdftex.map'))
10461046
for page in dvi:
1047-
print('=== new page ===')
1047+
print(f"=== new page === "
1048+
f"(w: {page.width}, h: {page.height}, d: {page.descent})")
10481049
for font, group in itertools.groupby(
10491050
page.text, lambda text: text.font):
1050-
print('font', font.texname, 'scaled', font._scale / 2 ** 20)
1051+
print(f"font: {font.texname.decode('latin-1')!r}\t"
1052+
f"scale: {font._scale / 2 ** 20}")
1053+
print("x", "y", "glyph", "chr", "w", "(glyphs)", sep="\t")
10511054
for text in group:
10521055
print(text.x, text.y, text.glyph,
10531056
chr(text.glyph) if chr(text.glyph).isprintable()
10541057
else ".",
1055-
text.width)
1056-
for x, y, w, h in page.boxes:
1057-
print(x, y, 'BOX', w, h)
1058+
text.width, sep="\t")
1059+
if page.boxes:
1060+
print("x", "y", "w", "h", "", "(boxes)", sep="\t")
1061+
for x, y, w, h in page.boxes:
1062+
print(x, y, w, h, sep="\t")

0 commit comments

Comments
 (0)