[sugar] New version of piemenu.py, and some cairo questions

Antoine van Gelder hummingbird
Tue Feb 27 03:41:25 EST 2007


Don Hopkins wrote:
> I could use some tips about measuring the bounding box of fonts and text 
> in cairo, please.


I gave up entirely on straight cairo text rendering and switched to 
pango - which ended up looking something like this:

self.pango_context = self.create_pango_context()
self.layout = pango.Layout(self.pango_context)
fontDescription = pango.FontDescription("Monospace 8")
self.layout.set_font_description(fontDescription)
self.layout.set_text(text)
(self.pixel_width, self.pixel_height) = self.layout.get_pixel_size()
cairo_context.show_layout(self.layout)

  - a


More information about the Sugar-devel mailing list