MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / get_text_path

Method get_text_path

site-packages/matplotlib/textpath.py:105–173  ·  view source on GitHub ↗

Convert text *s* to path (a tuple of vertices and codes for matplotlib.path.Path). Parameters ---------- prop : `matplotlib.font_manager.FontProperties` instance The font properties for the text. s : str The text to be conve

(self, prop, s, ismath=False, usetex=False)

Source from the content-addressed store, hash-verified

103 return w * scale, h * scale, d * scale
104
105 def get_text_path(self, prop, s, ismath=False, usetex=False):
106 """
107 Convert text *s* to path (a tuple of vertices and codes for
108 matplotlib.path.Path).
109
110 Parameters
111 ----------
112
113 prop : `matplotlib.font_manager.FontProperties` instance
114 The font properties for the text.
115
116 s : str
117 The text to be converted.
118
119 usetex : bool, optional
120 Whether to use tex rendering. Defaults to ``False``.
121
122 ismath : bool, optional
123 If True, use mathtext parser. Effective only if
124 ``usetex == False``.
125
126 Returns
127 -------
128
129 verts, codes : tuple of lists
130 *verts* is a list of numpy arrays containing the x and y
131 coordinates of the vertices. *codes* is a list of path codes.
132
133 Examples
134 --------
135
136 Create a list of vertices and codes from a text, and create a `Path`
137 from those::
138
139 from matplotlib.path import Path
140 from matplotlib.textpath import TextToPath
141 from matplotlib.font_manager import FontProperties
142
143 fp = FontProperties(family="Humor Sans", style="italic")
144 verts, codes = TextToPath().get_text_path(fp, "ABC")
145 path = Path(verts, codes, closed=False)
146
147 Also see `TextPath` for a more direct way to create a path from a text.
148 """
149 if not usetex:
150 if not ismath:
151 font = self._get_font(prop)
152 glyph_info, glyph_map, rects = self.get_glyphs_with_font(
153 font, s)
154 else:
155 glyph_info, glyph_map, rects = self.get_glyphs_mathtext(
156 prop, s)
157 else:
158 glyph_info, glyph_map, rects = self.get_glyphs_tex(prop, s)
159
160 verts, codes = [], []
161
162 for glyph_id, xposition, yposition, scale in glyph_info:

Callers 2

Calls 6

_get_fontMethod · 0.95
get_glyphs_with_fontMethod · 0.95
get_glyphs_mathtextMethod · 0.95
get_glyphs_texMethod · 0.95
arrayMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected