Draw the math text using matplotlib.mathtext.
(self, gc, x, y, s, prop, angle)
| 828 | |
| 829 | @_log_if_debug_on |
| 830 | def draw_mathtext(self, gc, x, y, s, prop, angle): |
| 831 | """Draw the math text using matplotlib.mathtext.""" |
| 832 | width, height, descent, glyphs, rects = \ |
| 833 | self._text2path.mathtext_parser.parse(s, 72, prop) |
| 834 | self.set_color(*gc.get_rgb()) |
| 835 | self._pswriter.write( |
| 836 | f"gsave\n" |
| 837 | f"{x:g} {y:g} translate\n" |
| 838 | f"{angle:g} rotate\n") |
| 839 | lastfont = None |
| 840 | for font, fontsize, ccode, glyph_index, ox, oy in glyphs: |
| 841 | # NOTE: We ignore the character code in the subset, because PS uses the |
| 842 | # glyph name to write text. The subset is only used to ensure that each one |
| 843 | # does not overflow format limits. |
| 844 | subset, _ = self._character_tracker.track_glyph( |
| 845 | font, ccode, glyph_index) |
| 846 | if (font.postscript_name, subset, fontsize) != lastfont: |
| 847 | lastfont = font.postscript_name, subset, fontsize |
| 848 | self._pswriter.write( |
| 849 | f"/{font.postscript_name}-{subset} {fontsize} selectfont\n") |
| 850 | glyph_name = font.get_glyph_name(glyph_index) |
| 851 | self._pswriter.write( |
| 852 | f"{ox:g} {oy:g} moveto\n" |
| 853 | f"/{glyph_name} glyphshow\n") |
| 854 | for ox, oy, w, h in rects: |
| 855 | self._pswriter.write(f"{ox} {oy} {w} {h} rectfill\n") |
| 856 | self._pswriter.write("grestore\n") |
| 857 | |
| 858 | @_log_if_debug_on |
| 859 | def draw_gouraud_triangles(self, gc, points, colors, trans): |
no test coverage detected