<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks, that's just what I needed! <br>
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. <br>
Using pango instead of the low level text api simplified the code, and
now it does more and looks nicer! <br>
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. <br>
I updated the demo to use some gratuitous markup in the top level menu.
<br>
<br>
<a class="moz-txt-link-freetext" href="http://www.donhopkins.com/home/piemenu.py">http://www.donhopkins.com/home/piemenu.py</a><br>
<br>
-Don<br>
<br>
<br>
Marco Pesenti Gritti wrote:
<blockquote cite="mid1172569785.2971.8.camel@localhost.localdomain"
type="cite">
<pre wrap="">On Tue, 2007-02-27 at 10:45 +0200, Antoine van Gelder wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Don Hopkins wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I could use some tips about measuring the bounding box of fonts and text
in cairo, please.
</pre>
</blockquote>
<pre wrap="">
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)
</pre>
</blockquote>
<pre wrap=""><!---->
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:
<a class="moz-txt-link-freetext" href="http://svn.mugshot.org/dumbhippo/trunk/client/common/canvas/hippo/hippo-canvas-text.c">http://svn.mugshot.org/dumbhippo/trunk/client/common/canvas/hippo/hippo-canvas-text.c</a>
Marco
</pre>
</blockquote>
<br>
</body>
</html>