[cairo] cairomm - userfonts
Behdad Esfahbod
behdad at behdad.org
Wed Jun 25 06:02:37 PDT 2008
On Wed, 2008-06-25 at 13:11 +0200, Murray Cumming wrote:
> On Mon, 2008-05-26 at 00:49 -0400, Behdad Esfahbod wrote:
> > On Sun, 2008-05-25 at 22:36 -0300, Felipe Sanches wrote:
> > > I started to read the cairomm code today because I am interested in
> > > coding the userfont cairomm binding but I faced the following problem:
> > > how do we deal with callbacks when writting a binding? I need to give
> > > to cairo a callback to a class method since cairo is written in C, how
> > > would it deal with the instance pointer (this) ?
> >
> > Hi,
> >
> > I'm no binding expert, but I believe the idea is that you can use the
> > user_data mechanism to attach arbitrary data to cairo objects. In this
> > case see cairo_scaled_font_set_user_data. You would stuff your method
> > and instance pointers into a struct and hook it to user_data, then
> > attach a callback that retrieves that user_data and calls the actual
> > callback...
>
> Yes, look for SignalProxy* in .ccg files in gtkmm. For instance,
> SignalProxy_Visible_gtk_callback here:
> http://svn.gnome.org/viewvc/gtkmm/trunk/gtk/src/treemodelfilter.ccg?view=markup
> (SignalProxy is not a great prefix for those really, but nevermind).
>
> I don't know if we had any need for this in cairomm already, but I guess
> we do for this new API.
>
> But exactly what callback do you mean. Could you name a specific cairo
> function, please?
Cairo user-font API is new 1.8 stuff. In no released cairo version yet.
The interesting part is:
typedef cairo_status_t (*cairo_user_scaled_font_init_func_t) (cairo_scaled_font_t *scaled_font,
cairo_font_extents_t *extents);
typedef cairo_status_t (*cairo_user_scaled_font_render_glyph_func_t) (cairo_scaled_font_t *scaled_font,
unsigned long glyph,
cairo_t *cr,
cairo_text_extents_t *extents);
typedef cairo_status_t (*cairo_user_scaled_font_text_to_glyphs_func_t) (cairo_scaled_font_t *scaled_font,
const char *utf8,
cairo_glyph_t **glyphs,
int *num_glyphs);
typedef cairo_status_t (*cairo_user_scaled_font_unicode_to_glyph_func_t) (cairo_scaled_font_t *scaled_font,
unsigned long unicode,
unsigned long *glyph_index);
/* User-font method setters */
cairo_public void
cairo_user_font_face_set_init_func (cairo_font_face_t *font_face,
cairo_user_scaled_font_init_func_t init_func);
cairo_public void
cairo_user_font_face_set_render_glyph_func (cairo_font_face_t *font_face,
cairo_user_scaled_font_render_glyph_func_t render_glyph_func);
cairo_public void
cairo_user_font_face_set_text_to_glyphs_func (cairo_font_face_t *font_face,
cairo_user_scaled_font_text_to_glyphs_func_t text_to_glyphs_func);
cairo_public void
cairo_user_font_face_set_unicode_to_glyph_func (cairo_font_face_t *font_face,
cairo_user_scaled_font_unicode_to_glyph_func_t unicode_to_glyph_func);
/* User-font method getters */
cairo_public cairo_user_scaled_font_init_func_t
cairo_user_font_face_get_init_func (cairo_font_face_t *font_face);
cairo_public cairo_user_scaled_font_render_glyph_func_t
cairo_user_font_face_get_render_glyph_func (cairo_font_face_t *font_face);
cairo_public cairo_user_scaled_font_text_to_glyphs_func_t
cairo_user_font_face_get_text_to_glyphs_func (cairo_font_face_t *font_face);
cairo_public cairo_user_scaled_font_unicode_to_glyph_func_t
cairo_user_font_face_get_unicode_to_glyph_func (cairo_font_face_t *font_face);
--
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