Store information to write a mathtext rendering to the PostScript backend.
| 215 | return image, depth |
| 216 | |
| 217 | class 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 |
| 235 | setfont |
| 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 | |
| 257 | class MathtextBackendPdf(MathtextBackend): |
| 258 | """ |