[cairo] font face in cairo-wrapper for php

Behdad Esfahbod behdad at behdad.org
Wed Mar 18 10:15:40 PDT 2009


On 03/18/2009 05:28 AM, Fan Zhang wrote:
> Hi,
>
> Does anyone know how to use
> void *cairo_select_font_face* ( resource cr, string fontname, int slant,
> int weight )
> for loading local fonts?
>
> i've tried to do
> cairo_select_font_face ($this->cr, arialbold.ttf,
>              CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
>
> and arialbold.ttf is in the same path of the php file, but it won't work.
>
> If cairo-wrapper only use the system font, where can i add new fonts?
> I'm using fedora and cairo is installed from YUM.

The PHP binding has the wrong parameter name.  The fontname parameter is 
actually a family name.  That is, a string like "Arial", or "DejaVu Sans".  If 
you want to use a font file, you'd need to use either fontconfig or freetype 
API directly to create a FcPattern or FT_Face and use the API in cairo-ft.h to 
use those with cairo.  Not sure if those are bound in the PHP bindings.

behdad

> Thanks


More information about the cairo mailing list