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

Method draw_tex

lib/matplotlib/backends/backend_agg.py:271–298  ·  view source on GitHub ↗
(self, gc, x, y, s, prop, angle, *, mtext=None)

Source from the content-addressed store, hash-verified

269 return w, h, d
270
271 def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
272 # docstring inherited
273 # todo, handle props, angle, origins
274
275 size = prop.get_size_in_points()
276
277 if mpl.rcParams["text.latex.engine"] == "latex+dvipng":
278 Z = self.get_texmanager().get_grey(s, size, self.dpi)
279 Z = (Z * 0xff).astype(np.uint8)
280 w, h, d = self.get_text_width_height_descent(s, prop, ismath="TeX")
281 xd = d * math.sin(math.radians(angle))
282 yd = d * math.cos(math.radians(angle))
283 x = round(x + xd)
284 y = round(y + yd)
285 self._renderer.draw_text_image(Z, x, y, angle, gc)
286 return
287
288 dvifile = self.get_texmanager().make_dvi(s, size)
289 with Dvi(dvifile, self.dpi) as dvi:
290 page, = dvi
291
292 self._draw_text_glyphs_and_boxes(
293 gc, x, y, angle,
294 ((get_font(text.font_path), text.font_size, text.index,
295 text.font_effects.get('slant', 0), text.font_effects.get('extend', 1),
296 text.x, text.y)
297 for text in page.text),
298 ((box.x, box.y, box.width, box.height) for box in page.boxes))
299
300 def get_canvas_width_height(self):
301 # docstring inherited

Callers

nothing calls this directly

Calls 8

DviClass · 0.90
get_fontFunction · 0.90
get_greyMethod · 0.80
get_texmanagerMethod · 0.80
make_dviMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected