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

Class MathtextBackendPs

site-packages/matplotlib/mathtext.py:217–255  ·  view source on GitHub ↗

Store information to write a mathtext rendering to the PostScript backend.

Source from the content-addressed store, hash-verified

215 return image, depth
216
217class MathtextBackendPs(MathtextBackend):
218 """
219 Store information to write a mathtext rendering to the PostScript
220 backend.
221 """
222 def __init__(self):
223 self.pswriter = StringIO()
224 self.lastfont = None
225
226 def render_glyph(self, ox, oy, info):
227 oy = self.height - oy + info.offset
228 postscript_name = info.postscript_name
229 fontsize = info.fontsize
230 symbol_name = info.symbol_name
231
232 if (postscript_name, fontsize) != self.lastfont:
233 ps = """/%(postscript_name)s findfont
234%(fontsize)s scalefont
235setfont
236""" % locals()
237 self.lastfont = postscript_name, fontsize
238 self.pswriter.write(ps)
239
240 ps = """%(ox)f %(oy)f moveto
241/%(symbol_name)s glyphshow\n
242""" % locals()
243 self.pswriter.write(ps)
244
245 def render_rect_filled(self, x1, y1, x2, y2):
246 ps = "%f %f %f %f rectfill\n" % (x1, self.height - y2, x2 - x1, y2 - y1)
247 self.pswriter.write(ps)
248
249 def get_results(self, box, used_characters):
250 ship(0, 0, box)
251 return (self.width,
252 self.height + self.depth,
253 self.depth,
254 self.pswriter,
255 used_characters)
256
257class MathtextBackendPdf(MathtextBackend):
258 """

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected