render font using a pango Layout

This commit is contained in:
Josh Holtrop 2012-05-22 14:23:35 -04:00
parent 16c53f9d84
commit 9fc544d9e4

View File

@ -15,13 +15,13 @@ class MyWidget(gtk.DrawingArea):
def expose(self, widget, event): def expose(self, widget, event):
cr = widget.window.cairo_create() cr = widget.window.cairo_create()
cr.select_font_face("Courier", layout = cr.create_layout()
cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL) layout.set_text("Hello")
cr.set_font_size(20) desc = pango.FontDescription("Mono Bold 27")
cr.set_source_rgb(1.0, 0.3, 0.0) layout.set_font_description(desc)
cr.move_to(0, 15) cr.move_to(10, 150)
cr.text_path("Hello") cr.update_layout(layout)
cr.stroke() cr.show_layout(layout)
def destroy(window): def destroy(window):
gtk.main_quit() gtk.main_quit()