[cairo] How are fonts loaded? Can I specify a search path?

Thomas Larsen Wessel mrvelle at gmail.com
Mon Sep 5 02:01:46 PDT 2011

I wrote a Python script that uses PyCairo to render text on image files. I
did this on Ubuntu Linux, and it worked well.

I used: select_font_face, e.g. cr.select_font_face('Tahoma',

Somehow it finds the correct corresponding font, but I don't really know how
it does that. I have a feeling like that something on the OS, some kind of
font handling utility, keeps track of all the fonts and their attributes and
offer these to the applications. But what, how and where?

So now, I need to run the same script from a FreeBSD machine. With no X
server btw. Whatever font I try to set, it always draw with the same boring
one. Is it possible to specify a search path for fonts for Cairo, while
still using the select_font_face approact (i.e. specifying name, slant and

I know it is possible to load a font file manually but I would really like
to avoid that, since my script is quite generic and uses different font
faces with different slant and weight, and that data (read from a csv file)
is specified as tuples of (font family, slant, weight).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20110905/baebcf2e/attachment.htm>

More information about the cairo mailing list