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

Method get_text_width_height_descent

lib/matplotlib/textpath.py:46–68  ·  view source on GitHub ↗
(self, s, prop, ismath)

Source from the content-addressed store, hash-verified

44 return urllib.parse.quote(f"{font.postscript_name}-{glyph:x}")
45
46 def get_text_width_height_descent(self, s, prop, ismath):
47 fontsize = prop.get_size_in_points()
48
49 if ismath == "TeX":
50 return TexManager().get_text_width_height_descent(s, fontsize)
51
52 scale = fontsize / self.FONT_SCALE
53
54 if ismath:
55 prop = prop.copy()
56 prop.set_size(self.FONT_SCALE)
57 width, height, descent, *_ = \
58 self.mathtext_parser.parse(s, 72, prop)
59 return width * scale, height * scale, descent * scale
60
61 font = self._get_font(prop)
62 font.set_text(s, 0.0, flags=LoadFlags.NO_HINTING)
63 w, h = font.get_width_height()
64 w /= 64.0 # convert from subpixels
65 h /= 64.0
66 d = font.get_descent()
67 d /= 64.0
68 return w * scale, h * scale, d * scale
69
70 def get_text_path(self, prop, s, ismath=False, *, features=None, language=None):
71 """

Callers 1

_text_metricsFunction · 0.45

Calls 7

_get_fontMethod · 0.95
TexManagerClass · 0.90
get_width_heightMethod · 0.80
copyMethod · 0.45
set_sizeMethod · 0.45
parseMethod · 0.45
set_textMethod · 0.45

Tested by

no test coverage detected