[cairo] User font feature

Kristian Høgsberg krh at bitplanet.net
Sun Apr 9 23:00:38 PDT 2006

On 4/10/06, Behdad Esfahbod <behdad at cs.toronto.edu> wrote:
> On Mon, 10 Apr 2006, Kristian Høgsberg wrote:
> > I was thinking that you'd set any data you need as user data on the
> > cairo_font_face_t object.  We've preferred this approach before to
> > adding callback specific data and corresponding destroy funcs.
> I like to reserve them for the user of the font, not the backend.
> Even if we decide to use them, it will be really hard, unless you
> do add a font_face_create callback to set the user_data in it,
> but leaving it to the caller of cairo_user_font_face_create to
> know he should attach this data to this key after getting a
> font_face doesn't sound right to me.  Moreover, user_data keys
> are plain integers.  That makes it painful to choose keys without
> risking clashes with other users of the user_data.  Not sure what
> the original intention for adding them was.  No current backend
> users them I suppose.

No, the keys are pointers not integers.  The idea is that you use the
address of a static cairo_user_data_key_t object which will always be
unique.  And I'm not sure I see the problem in doing:

  face = cairo_user_font_face_create(...);
  cairo_font_face_set_user_data (face, &pdf_type3_font_key,
pdf_type3_object,, pdf_type3_object_destroy);

We shouldn't need to call any user provided callbacks from
cairo_user_font_face_create(), so I don't see the problem in setting
the user data after creation.  That said, I'm not greatly attached to
using user data for this, but I believe Carl and Keith have had a bias
towards not adding custom user data and extra destroy callbacks.


More information about the cairo mailing list