Skip to content

Commit 1a639e2

Browse files
authored
Merge pull request matplotlib#20165 from anntzer/dvidebug
Slightly improve output of dvi debug utilities, and tiny cleanups.
2 parents 84e0fab + 3fb9d07 commit 1a639e2

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
@@ -260,8 +260,8 @@ def _output(self):
260260
for elt in self.text + self.boxes:
261261
if isinstance(elt, Box):
262262
x, y, h, w = elt
263-
e = 0 # zero depth
264-
else: # glyph
263+
e = 0 # zero depth
264+
else: # glyph
265265
x, y, font, g, w = elt
266266
h, e = font._height_depth_of(g)
267267
minx = min(minx, x)
@@ -1053,14 +1053,19 @@ def _fontfile(cls, suffix, texname):
10531053
with Dvi(args.filename, args.dpi) as dvi:
10541054
fontmap = PsfontsMap(find_tex_file('pdftex.map'))
10551055
for page in dvi:
1056-
print('=== new page ===')
1056+
print(f"=== new page === "
1057+
f"(w: {page.width}, h: {page.height}, d: {page.descent})")
10571058
for font, group in itertools.groupby(
10581059
page.text, lambda text: text.font):
1059-
print('font', font.texname, 'scaled', font._scale / 2 ** 20)
1060+
print(f"font: {font.texname.decode('latin-1')!r}\t"
1061+
f"scale: {font._scale / 2 ** 20}")
1062+
print("x", "y", "glyph", "chr", "w", "(glyphs)", sep="\t")
10601063
for text in group:
10611064
print(text.x, text.y, text.glyph,
10621065
chr(text.glyph) if chr(text.glyph).isprintable()
10631066
else ".",
1064-
text.width)
1065-
for x, y, w, h in page.boxes:
1066-
print(x, y, 'BOX', w, h)
1067+
text.width, sep="\t")
1068+
if page.boxes:
1069+
print("x", "y", "w", "h", "", "(boxes)", sep="\t")
1070+
for x, y, w, h in page.boxes:
1071+
print(x, y, w, h, sep="\t")

0 commit comments

Comments
 (0)