[cairo] Early Initialization?

Behdad Esfahbod behdad at behdad.org
Wed Mar 21 07:21:09 PDT 2007

On Wed, 2007-03-21 at 14:28 +0100, Johannes Schmid wrote:
> Hi Behded!
> Behdad Esfahbod schrieb:
> >> Create an image surface and render something in the default language and
> >> default font ("Sans"?) to it using pangocairo.
> > 
> > For extra, do it for all font-descriptions that your UI uses (all
> > "default" font face+size combinations).
> I am not very familiar to cairo but I tried this without any speed-up:
> context = pango_cairo_font_map_create_context (
> 	PANGO_CAIRO_FONT_MAP(pango_cairo_font_map_get_default()));
> pango_context_load_font (context, 	
> 	pango_font_description_from_string("Sans"));

Probably because as Owen says, fontconfig doesn't have that much of a
startup overhead anymore.  So what we can aim for is to populate pango's
cache of fontsets.  For that to work, you need to use the exact font
description that is going to be used later...  So, just "Sans" may not
be enough.  I suggest you create a context from a Gtk+ widget for
example (gtk_widget_create_context).  That ensures that you get the font
from the style right.

> Maybe someone could point me to the methods I should use to render
> something to the pango image surface because I could not figure out yet
> with the reference documentation.

pango_cairo_show_layout() works.

> Thanks and regards,
> Johannes


"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759

More information about the cairo mailing list