MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _output

Method _output

lib/matplotlib/dviread.py:286–329  ·  view source on GitHub ↗

Output the text and boxes belonging to the most recent page. page = dvi._output()

(self)

Source from the content-addressed store, hash-verified

284 self.file.close()
285
286 def _output(self):
287 """
288 Output the text and boxes belonging to the most recent page.
289 page = dvi._output()
290 """
291 minx = miny = np.inf
292 maxx = maxy = -np.inf
293 maxy_pure = -np.inf
294 for elt in self.text + self.boxes:
295 if isinstance(elt, Box):
296 x, y, h, w = elt
297 e = 0 # zero depth
298 else: # glyph
299 x, y, font, g, w = elt
300 h, e = font._height_depth_of(g)
301 minx = min(minx, x)
302 miny = min(miny, y - h)
303 maxx = max(maxx, x + w)
304 maxy = max(maxy, y + e)
305 maxy_pure = max(maxy_pure, y)
306 if self._baseline_v is not None:
307 maxy_pure = self._baseline_v # This should normally be the case.
308 self._baseline_v = None
309
310 if not self.text and not self.boxes: # Avoid infs/nans from inf+/-inf.
311 return Page(text=[], boxes=[], width=0, height=0, descent=0)
312
313 if self.dpi is None:
314 # special case for ease of debugging: output raw dvi coordinates
315 return Page(text=self.text, boxes=self.boxes,
316 width=maxx-minx, height=maxy_pure-miny,
317 descent=maxy-maxy_pure)
318
319 # convert from TeX's "scaled points" to dpi units
320 d = self.dpi / (72.27 * 2**16)
321 descent = (maxy - maxy_pure) * d
322
323 text = [Text((x-minx)*d, (maxy-y)*d - descent, f, g, w*d)
324 for (x, y, f, g, w) in self.text]
325 boxes = [Box((x-minx)*d, (maxy-y)*d - descent, h*d, w*d)
326 for (x, y, h, w) in self.boxes]
327
328 return Page(text=text, boxes=boxes, width=(maxx-minx)*d,
329 height=(maxy_pure-miny)*d, descent=descent)
330
331 def _read(self):
332 """

Callers 1

__iter__Method · 0.95

Calls 3

BoxClass · 0.85
_height_depth_ofMethod · 0.80
TextClass · 0.70

Tested by

no test coverage detected