move cairo position based on line height
This commit is contained in:
parent
23ddad074f
commit
59cfa01e6e
@ -16,8 +16,11 @@ class MyWidget(gtk.DrawingArea):
|
||||
def expose(self, widget, event):
|
||||
cr = widget.window.cairo_create()
|
||||
layout = cr.create_layout()
|
||||
desc = pango.FontDescription("Mono Bold 27")
|
||||
desc = pango.FontDescription("Mono Bold 20")
|
||||
layout.set_font_description(desc)
|
||||
layout.set_text("M")
|
||||
extents = layout.get_pixel_extents()
|
||||
line_height = extents[1][3] - extents[1][1]
|
||||
|
||||
cr.set_source_rgb(1.0, 0.4, 0.0)
|
||||
cr.move_to(10, 10)
|
||||
@ -26,13 +29,13 @@ class MyWidget(gtk.DrawingArea):
|
||||
cr.show_layout(layout)
|
||||
|
||||
cr.set_source_rgb(0.0, 0.0, 0.0)
|
||||
cr.move_to(10, 50)
|
||||
cr.move_to(10, 10 + line_height)
|
||||
layout.set_text("BLACK: Q")
|
||||
cr.update_layout(layout)
|
||||
cr.show_layout(layout)
|
||||
|
||||
cr.set_source_rgb(0.0, 0.0, 1.0)
|
||||
cr.move_to(10, 90)
|
||||
cr.move_to(10, 10 + line_height * 2)
|
||||
layout.set_text("multiline\nlayout")
|
||||
cr.update_layout(layout)
|
||||
cr.show_layout(layout)
|
||||
|
Loading…
x
Reference in New Issue
Block a user