[cairo] Loading font from a file in pycairo

Steven Chaplin stevech1097 at yahoo.com.au
Fri Aug 10 19:10:32 PDT 2007


On Fri, 2007-08-10 at 14:36 -0400, Michael Droettboom wrote:
> I'm making some improvements to the Cairo backend in matplotlib and I 
> have question about font loading.
> 
> matplotlib has its own font-finding infrastructure, and most of the 
> rendering backends load fonts by a filename returned from that system. 
The Matplotlib font_manager has reinvented the wheel - fontconfig could
have been used instead (by writing Python bindings) giving a font
interface which is consistent to that used by many other applications
(and probably solving your current problem).

> Is there any way to load a font by its filename in pycairo?
> 
> It looks like it is possible in C to load a freetype font with 
> FT_Open_Face and then use cairo_ft_font_face_create_for_ft_face.  Is 
> freetype always assumed to be on all platforms, or would one have to use 
> cairo_win32_font_face_create_for_hfont, for example, on Windows?
> 
> Are there any thoughts about exposing this in pycairo?  Is this just a 
> bad idea for reasons that I might be missing?
For pycairo to expose the cairo/FreeType functions there would need to be
a Python binding for FreeType which provides a C API which pycairo could
use (FreeType bindings do not belong in pycairo, the same way that the
FreeType C library does not belong in cairo). There have been a couple
of FreeType python bindings written in the past but I don't think they
are still maintained.

> Cheers,
> Mike
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo



More information about the cairo mailing list