[sugar] sugar system font in cairo

Antoine van Gelder hummingbird
Tue Nov 7 04:01:26 EST 2006


Erik Blankinship wrote:
> Thanks for the warning about cairo's font rendering.
> 
> Could you please send a reference to how to use pangocairo with
> pycairo?  I think that would be helpful for everyone on this list who
> might use text in their application.

class Foo(gtk.DrawingArea):
  def __init__(self):
    super(Foo, self).__init__()
    self.connect("expose_event", self.expose)

  def expose(self, widget, event):
    self.context = widget.window.cairo_create()
    self.pango_context = self.create_pango_context()
    context.move_to(0, 0);
    font_desc = pango.FontDescription('Serif 12')
    layout = pango.Layout(self.pango_context)
    layout.set_font_description(font_desc)
    layout.set_text("Hello!")
    context.show_layout(layout)

 - a


More information about the Sugar-devel mailing list