(self, gc, x, y, s, prop, angle)
| 2154 | self.file.output(0, 0, Op.textpos) |
| 2155 | |
| 2156 | def draw_mathtext(self, gc, x, y, s, prop, angle): |
| 2157 | # TODO: fix positioning and encoding |
| 2158 | width, height, descent, glyphs, rects = \ |
| 2159 | self._text2path.mathtext_parser.parse(s, 72, prop) |
| 2160 | |
| 2161 | if gc.get_url() is not None: |
| 2162 | self.file._annotations[-1][1].append(_get_link_annotation( |
| 2163 | gc, x, y, width, height, angle)) |
| 2164 | |
| 2165 | fonttype = mpl.rcParams['pdf.fonttype'] |
| 2166 | |
| 2167 | # Set up a global transformation matrix for the whole math expression |
| 2168 | a = math.radians(angle) |
| 2169 | self.file.output(Op.gsave) |
| 2170 | self.file.output(math.cos(a), math.sin(a), |
| 2171 | -math.sin(a), math.cos(a), |
| 2172 | x, y, Op.concat_matrix) |
| 2173 | |
| 2174 | self.check_gc(gc, gc._rgb) |
| 2175 | prev_font = None, None |
| 2176 | oldx, oldy = 0, 0 |
| 2177 | |
| 2178 | self.file.output(Op.begin_text) |
| 2179 | for font, fontsize, ccode, glyph_index, ox, oy in glyphs: |
| 2180 | subset_index, subset_charcode = self.file._character_tracker.track_glyph( |
| 2181 | font, ccode, glyph_index) |
| 2182 | font_path = FontPath(font.fname, font.face_index) |
| 2183 | self._setup_textpos(ox, oy, 0, oldx, oldy) |
| 2184 | oldx, oldy = ox, oy |
| 2185 | if (font_path, subset_index, fontsize) != prev_font: |
| 2186 | self.file.output(self.file.fontName(font_path, subset_index), fontsize, |
| 2187 | Op.selectfont) |
| 2188 | prev_font = font_path, subset_index, fontsize |
| 2189 | self.file.output(self._encode_glyphs([subset_charcode], fonttype), |
| 2190 | Op.show) |
| 2191 | self.file.output(Op.end_text) |
| 2192 | |
| 2193 | # Draw any horizontal lines in the math layout |
| 2194 | for ox, oy, width, height in rects: |
| 2195 | self.file.output(Op.gsave, ox, oy, width, height, |
| 2196 | Op.rectangle, Op.fill, Op.grestore) |
| 2197 | |
| 2198 | # Pop off the global transformation |
| 2199 | self.file.output(Op.grestore) |
| 2200 | |
| 2201 | def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None): |
| 2202 | # docstring inherited |
no test coverage detected