Thanks, that's just what I needed!
I've converted piemenu.py to use pango and markup text, so you can have
multi-line labels and headers with html markup in them.
Using pango instead of the low level text api simplified the code, and
now it does more and looks nicer!
Now you configure the fonts with simple pango font description strings
like "Helvetica bold 24", instead of having a bunch of obnoxious
instance variables for font family, weight, slant, size.
I updated the demo to use some gratuitous markup in the top level menu.
http://www.donhopkins.com/home/piemenu.py
-Don
Marco Pesenti Gritti wrote:
On Tue, 2007-02-27 at 10:45 +0200, Antoine van Gelder wrote:
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)
Yeah, I think the preferred way to do text rendering is to use pango.
For a more complex example see the hippo canvas text item:
http://svn.mugshot.org/dumbhippo/trunk/client/common/canvas/hippo/hippo-canvas-text.c
Marco
_______________________________________________
Sugar mailing list
[email protected]
http://mailman.laptop.org/mailman/listinfo/sugar