[cairo] [API] unbreak CAIRO_FONT_TYPE_ATSUI

Vladimir Vukicevic vladimir at pobox.com
Mon Mar 24 12:20:02 PDT 2008


On Mar 23, 2008, at 12:29 PM, Benjamin Otte wrote:

> Hey,
>
> Vlad thought it'd be a good idea, to write to the list about the
> recent commit 9a1f7bbc as it touches public API. The s/ATSUI/QUARTZ/
> rename broke API compatibility to cairo 1.4 and I reverted that, so
> programs like the following trivial example continue to compile and
> work unchanged:
> #include <cairo.h>
> int main ()
> {
>  return CAIRO_FONT_TYPE_ATSUI;
> }
> Note that this example is not using any experimental features - it can
> be compiled against pure Cairo.
>
> I was pretty sure that making the old symbol work again properly was
> the correct thing to do. In fact, I was guided by
> CAIRO_FORMAT_RGB16_565, another deprecated enum value.
> If it was not correct, feel free to revert it.

I'm ok with this change, but I would prefer to get rid of the ATSUI  
name entirely in case someone expects it to actually use ATSUI in the  
future.  The behaviour won't change though, so maybe it's ok to just  
#define it.  But up to carl and behdad; we should come up with some  
kind of policy for those enums, since I bet this will come up again in  
the future.

It would be nice to get rid of the enums from cairo.h entirely to  
avoid this problem; I thought about this a little while ago, but never  
wrote up a suggestion.  Here's one thing that could be done:

typedef char *cairo_surface_identifier_t;
typedef void *cairo_surface_type_t;

struct _surface_backend {
   cairo_surface_identifier_t ident;
   ...
};

surface_backed image_surface = {
    "Image Surface",
    ... functions ...
};

cairo_surface_type_t
image_surface_get_type() {
   return (cairo_surface_type_t) backend.ident;
}

and then some compat defines:

#define CAIRO_SURFACE_TYPE_IMAGE  (cairo_image_surface_get_type())

The only thing that breaks with this is that you can't use the values  
in case statements any more, but I'd think that's pretty uncommon in  
user code.

      - Vlad



More information about the cairo mailing list