Ejemplo n.º 1
0
Archivo: text.py Proyecto: clones/kaa
    def set_font(self, font, size = 24):
        try:
            if type(font) in types.StringTypes:
                self.font = imagelib.load_font(font, size)
            else:
                self.font = font
            if hasattr(self, "text") and \
                   (font, size) != (self.fontname, self.size):
                # Need to re-render text with new font and/or size.
                self.set_text(self.text, force = True)
        except IOError:
            print "Font %s/%d failed to load, so using default" % (font, size)
            self.font = imagelib.load_font("arial", 24)

        self.fontname, self.size = self.font.fontname, self.font.size
Ejemplo n.º 2
0
Archivo: image.py Proyecto: clones/kaa
 def draw_text(self, text, pos = (0, 0), font = "arial", size = 24,
               color = (255,255,255,255)):
     """
     Draws the given text over the image at position 'pos', a tuple holding
     the left and top coordinates, with the supplied font, size, and color.
     color is a tuple holding the RGBA values for the text.
     """
     if type(font) in types.StringTypes:
         font = imagelib.load_font(font, size)
     metrics = self.image.draw_text(pos, text, color, font)
     self._image_changed()
     return metrics