[cairo] Freetype to Cairo - newb needs help
Behdad Esfahbod
behdad at behdad.org
Tue Oct 23 09:04:01 PDT 2007
On Tue, 2007-10-23 at 16:48 +0200, Donn wrote:
> > The functions take FT_Library* and FT_Face* though. You can wrap them
> > like both are simple ints.
>
> I tried these:
>
> >>> from ctypes import *
> >>> f=CDLL("libfreetype.so")
> >>> c=CDLL("libcairo.so")
>
> >>> face=c_void_p()
> >>> lib=c_void_p()
> >>> f.FT_New_Face(lib,"F.TTF",0,face)
> 6
The 6 return value is an error. Because you have not initialized lib
and/or that you are not passing face by reference. Note that the C
prototype is FT_Face *, not FT_Face.
> >>> cairoface = c.cairo_ft_font_face_create_for_ft_face(face)
> Segmentation fault
Fixing those, it works:
from ctypes import *
f=CDLL("libfreetype.so")
lib=c_void_p()
print f.FT_Init_FreeType (byref (lib))
face=c_void_p()
print f.FT_New_Face (lib,
"/usr/share/fonts/dejavu-lgc/DejaVuLGCSans.ttf", 0, byref(face))
c=CDLL("libcairo.so")
cairoface = c.cairo_ft_font_face_create_for_ft_face (face)
print cairoface
However, I'm not sure how I can trick pygtk into creating a
cairo.FontFace object out of the int/pointer cairoface that I've got.
behdad
> Tried again:
> >>> face=c_int()
> >>> lib=c_int()
>
> >>> f.FT_New_Face(lib,"F.TTF",0,face)
> 6
>
> >>> cairoface = c.cairo_ft_font_face_create_for_ft_face(face)
> Segmentation fault
>
>
> What's the better procedure?
> /d
--
behdad
http://behdad.org/
"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