render font using a pango Layout
This commit is contained in:
parent
16c53f9d84
commit
9fc544d9e4
14
example.py
14
example.py
@ -15,13 +15,13 @@ class MyWidget(gtk.DrawingArea):
|
||||
|
||||
def expose(self, widget, event):
|
||||
cr = widget.window.cairo_create()
|
||||
cr.select_font_face("Courier",
|
||||
cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
|
||||
cr.set_font_size(20)
|
||||
cr.set_source_rgb(1.0, 0.3, 0.0)
|
||||
cr.move_to(0, 15)
|
||||
cr.text_path("Hello")
|
||||
cr.stroke()
|
||||
layout = cr.create_layout()
|
||||
layout.set_text("Hello")
|
||||
desc = pango.FontDescription("Mono Bold 27")
|
||||
layout.set_font_description(desc)
|
||||
cr.move_to(10, 150)
|
||||
cr.update_layout(layout)
|
||||
cr.show_layout(layout)
|
||||
|
||||
def destroy(window):
|
||||
gtk.main_quit()
|
||||
|
Loading…
x
Reference in New Issue
Block a user