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

Method _draw_text_as_path

lib/matplotlib/backend_bases.py:545–576  ·  view source on GitHub ↗

Draw the text by converting them to paths using `.TextToPath`. This private helper supports the same parameters as `~.RendererBase.draw_text`; setting *ismath* to "TeX" triggers TeX rendering.

(self, gc, x, y, s, prop, angle, ismath, mtext)

Source from the content-addressed store, hash-verified

543 self._draw_text_as_path(gc, x, y, s, prop, angle, ismath, mtext)
544
545 def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath, mtext):
546 """
547 Draw the text by converting them to paths using `.TextToPath`.
548
549 This private helper supports the same parameters as
550 `~.RendererBase.draw_text`; setting *ismath* to "TeX" triggers TeX
551 rendering.
552 """
553 if mtext is not None:
554 features = mtext.get_fontfeatures()
555 language = mtext.get_language()
556 else:
557 features = language = None
558 text2path = self._text2path
559 fontsize = self.points_to_pixels(prop.get_size_in_points())
560 verts, codes = text2path.get_text_path(prop, s, ismath=ismath,
561 features=features, language=language)
562 path = Path(verts, codes)
563 if self.flipy():
564 width, height = self.get_canvas_width_height()
565 transform = (Affine2D()
566 .scale(fontsize / text2path.FONT_SCALE)
567 .rotate_deg(angle)
568 .translate(x, height - y))
569 else:
570 transform = (Affine2D()
571 .scale(fontsize / text2path.FONT_SCALE)
572 .rotate_deg(angle)
573 .translate(x, y))
574 color = gc.get_rgb()
575 gc.set_linewidth(0.0)
576 self.draw_path(gc, path, transform, rgbFace=color)
577
578 def get_text_width_height_descent(self, s, prop, ismath):
579 """

Callers 2

draw_texMethod · 0.95
draw_textMethod · 0.95

Calls 14

points_to_pixelsMethod · 0.95
flipyMethod · 0.95
draw_pathMethod · 0.95
PathClass · 0.90
Affine2DClass · 0.90
get_fontfeaturesMethod · 0.80
get_languageMethod · 0.80
get_text_pathMethod · 0.80
translateMethod · 0.80
rotate_degMethod · 0.80
scaleMethod · 0.45

Tested by

no test coverage detected