def render(self, box): # first pass to calculate size ship(self, 0, 0, box) minx = min(self.xvalues) - 1 maxx = max(self.xvalues) + 1 miny = min(self.yvalues) - 1 maxy = max(self.yvalues) + 1 width = maxx - minx height = maxy - miny - box.depth depth = maxy - miny - box.height image = ft.FT2Image(math.ceil(width), math.ceil(height + depth)) # second pass self.calcsize = False ship(self, -minx, -miny, box) for ox, oy, info in self.glyps: thetext = unichr_safe(info.num) ccode = ord(thetext) info.font.set_size(info.fontsize, 72) glyph = info.font.load_char(ccode) info.font.draw_glyph_to_bitmap(image, ox, oy - info.metrics.iceberg, glyph) for x1, y1, x2, y2 in self.rects: image.draw_rect_filled(x1, y1, x2, y2) return image
def render_glyph(self, ox, oy, info): """ Draw a glyph described by *info* to the reference point (*ox*,*oy*). """ font = info.font.fname if not self.fontcallback is None: self.fontcallback(font) oy = self.height - oy + info.offset self.canvas.setFont(font, info.fontsize) self.canvas.drawString(ox, oy, unichr_safe(info.num))
def render_glyph(self, ox, oy, info): """ Draw a glyph described by *info* to the reference point (*ox*,*oy*). """ thetext = unichr_safe(info.num) defid = info.font.SVGDefID(thetext, info.fontsize) args =(ox, self.depth + oy - info.offset - self.height) transform = "translate(%g,%g)" % args obj = self.svg.Use(transform = transform) obj.set('xlink:href', '#%s' % defid) if not defid in self.seen: self.seen.add(defid) path = info.font.SVGGlyph(ord(thetext), info.fontsize) self.root.Path(id = defid, d = path)
def render_glyph(self, ox, oy, info): """ Draw a glyph described by *info* to the reference point (*ox*,*oy*). """ thetext = unichr_safe(info.num) defid = info.font.SVGDefID(thetext, info.fontsize) args = (ox, self.depth + oy - info.offset - self.height) transform = "translate(%g,%g)" % args obj = self.svg.Use(transform=transform) obj.set('xlink:href', '#%s' % defid) if not defid in self.seen: self.seen.add(defid) path = info.font.SVGGlyph(ord(thetext), info.fontsize) self.root.Path(id=defid, d=path)