Source

vanhoek / vanhoek / primitives / text.py

Full commit
import cairo
try:
    from ._freetype_fonts import create_cairo_font_face_for_file
except ImportError:
    print "FreeType not available."

class TextObject(object):
    def __init__(self, text, position, color = (0.0,0.0,0.0,1.0)):
        self.text = text
        self.position = position
        self.color = color

    def render(self, context):
        context.set_source_rgba(*self.color)
        context.move_to(self.position[0], self.position[1])
        context.select_font_face("Sans")
        context.set_font_size(80)
        context.show_text(self.text)