convert the string *s* to vertices and codes by parsing it with mathtext.
(self, prop, s, glyph_map=None,
return_new_glyphs_only=False)
| 233 | glyph_map_new, rects) |
| 234 | |
| 235 | def get_glyphs_mathtext(self, prop, s, glyph_map=None, |
| 236 | return_new_glyphs_only=False): |
| 237 | """ |
| 238 | convert the string *s* to vertices and codes by parsing it with |
| 239 | mathtext. |
| 240 | """ |
| 241 | |
| 242 | prop = prop.copy() |
| 243 | prop.set_size(self.FONT_SCALE) |
| 244 | |
| 245 | width, height, descent, glyphs, rects = self.mathtext_parser.parse( |
| 246 | s, self.DPI, prop) |
| 247 | |
| 248 | if not glyph_map: |
| 249 | glyph_map = OrderedDict() |
| 250 | |
| 251 | if return_new_glyphs_only: |
| 252 | glyph_map_new = OrderedDict() |
| 253 | else: |
| 254 | glyph_map_new = glyph_map |
| 255 | |
| 256 | xpositions = [] |
| 257 | ypositions = [] |
| 258 | glyph_ids = [] |
| 259 | sizes = [] |
| 260 | |
| 261 | currx, curry = 0, 0 |
| 262 | for font, fontsize, ccode, ox, oy in glyphs: |
| 263 | char_id = self._get_char_id(font, ccode) |
| 264 | if char_id not in glyph_map: |
| 265 | font.clear() |
| 266 | font.set_size(self.FONT_SCALE, self.DPI) |
| 267 | glyph = font.load_char(ccode, flags=LOAD_NO_HINTING) |
| 268 | glyph_map_new[char_id] = self.glyph_to_path(font) |
| 269 | |
| 270 | xpositions.append(ox) |
| 271 | ypositions.append(oy) |
| 272 | glyph_ids.append(char_id) |
| 273 | size = fontsize / self.FONT_SCALE |
| 274 | sizes.append(size) |
| 275 | |
| 276 | myrects = [] |
| 277 | for ox, oy, w, h in rects: |
| 278 | vert1 = [(ox, oy), (ox, oy + h), (ox + w, oy + h), |
| 279 | (ox + w, oy), (ox, oy), (0, 0)] |
| 280 | code1 = [Path.MOVETO, |
| 281 | Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO, |
| 282 | Path.CLOSEPOLY] |
| 283 | myrects.append((vert1, code1)) |
| 284 | |
| 285 | return (list(zip(glyph_ids, xpositions, ypositions, sizes)), |
| 286 | glyph_map_new, myrects) |
| 287 | |
| 288 | def get_texmanager(self): |
| 289 | """ |
no test coverage detected