[cairo] User font take 2

Kristian Høgsberg krh at bitplanet.net
Mon May 8 11:28:07 PDT 2006


On 5/8/06, Torsten Schoenfeld <kaffeetisch at gmx.de> wrote:
> On Mon, 2006-05-08 at 12:34 -0400, Kristian Høgsberg wrote:
>
> > So, to flesh out the API a bit more, here's what I think would work (I
> > haven't implemented this yet, just looking for comments):
>
> I have two small comments on the naming from a language binding point of
> view.  These are solely based on the names of the functions/methods, so
> my arguments become irrelevant if there are specific reasons for the
> names.
>
> >     cairo_font_face_t *
> >     cairo_create_user_font_face(cairo_matrix_t *glyph_to_user);
>
> Functions that have the cairo_ prefix should either create a cairo_t or
> have a cairo_t as their first argument.  This function looks like a
> cairo_font_face_t constructor, so maybe give it a cairo_font_face_
> prefix?  (Though that would probably become rather long.)

Oops, yep, this should be cairo_user_font_face_create().

> >     cairo_t *
> >     cairo_user_font_face_add_glyph(cairo_font_face_t    *font_face,
> >                                    cairo_content_t       content,
> >                                    cairo_text_extents_t *metrics,
> >                                    int                   ucs4,
> >                                    int                   index);
>
> This has a cairo_user_font_face_ prefix but takes a cairo_font_face_t as
> its first argument.  The prefix of a method should match the object that
> method works on.  Also, the name doesn't really state that this method
> returns a new cairo_t.

This is unfortunate, but in line with the rest of the API.  The cairo
API generally don't export the subtypes of the different objects, so
in cases where we have functions that operate exclusively on one
specific subtype we loose type safety. Other examples are
cairo_xlib_surface_set_drawable(), cairo_ps_surface_set_size(),
cairo_pattern_add_color_stop_rgb() (well in this case the names match,
but it only works for gradient patterns).

Thanks,
Kristian


More information about the cairo mailing list