I forward this the the list because it's an interesting solution. It's not a Python wrapper at all, but in a cloudy room no one would notice :)
---------- Forwarded Message ---------- Subject: Re: [cairo] Freetype to Cairo - newb needs help Date: Tuesday 23 October 2007 20:48 From: Bertram Felgenhauer <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Donn wrote: > > Fixing those, it works: > > Ah, I see. A little dizzy, but glad it's getting further. Now the thing, as > you mentioned, is casting the returned pointer, cairo_font_face_t, to a > cairo.FontFace object ... I'm all out. It's not exactly trivial. The code below works for me. I'm not sure how brittle it is. HTH, Bertram ######################################################################## import cairo import ctypes # find DLLs cairo_dll = ctypes.CDLL("libcairo.so") freetype_dll = ctypes.CDLL("libfreetype.so") # this makes pycairo's internals available. pycairo_dll = ctypes.PyDLL(cairo._cairo.__file__) # specify some types cairo_dll.cairo_ft_font_face_create_for_ft_face.restype = ctypes.c_void_p pycairo_dll.PycairoFontFace_FromFontFace.restype = ctypes.py_object # initialise freetype ft_lib = ctypes.c_void_p() freetype_dll.FT_Init_FreeType(ctypes.byref(ft_lib)) # load font ft_face = ctypes.c_void_p() freetype_dll.FT_New_Face(ft_lib, "F.TTF", 0, ctypes.byref(ft_face)) # create cairo font face cr_face_raw = cairo_dll.cairo_ft_font_face_create_for_ft_face(ft_face, 0) cairo_dll.cairo_font_face_reference(cr_face_raw) # now wrap it properly using pycairo cr_face = pycairo_dll.PycairoFontFace_FromFontFace(cr_face_raw) # the rest is pretty easy surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 128, 128) ctx = cairo.Context(surface) ctx.set_font_face(cr_face) ctx.set_font_size(30) ctx.move_to(0, 44) ctx.show_text("Hello,") ctx.move_to(30, 74) ctx.show_text("world!") del ctx surface.write_to_png("hello.png") _______________________________________________ cairo mailing list [EMAIL PROTECTED] http://lists.cairographics.org/mailman/listinfo/cairo ------------------------------------------------------- -- You can't convince a believer of anything; for their belief is not based on evidence, it's based on a deep seated need to believe. -- Carl Sagan _______________________________________________ Freetype-devel mailing list Freetype-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-devel