[cairo] font lifetime

Owen Taylor otaylor at redhat.com
Wed Jan 26 20:37:04 PST 2005


On Wed, 2005-01-26 at 07:02 -0800, Keith Packard wrote:
> Around 8 o'clock on Jan 26, Owen Taylor wrote:
> 
> > One of the outstanding issues ... see my last long mail on fonts. I want
> > to add a destroy notifier, but am getting resistance on the subject.
> 
> The alternative I've proposed is a function which you can call when you 
> are "done" with the cairo_font_t object which guarantees that the FT_face 
> will not be referenced again but doesn't destroy the cairo_font_t object.
> 
> I prefer this method both because it fits neatly into how I envision automatic 
> memory management environments and also because it avoids callbacks from 
> cairo with indeterminant threading liabilities.
> 
> It's clear that either will work for C usage.   It's also clear we could 
> do both, but I'm sure most would agree that a single method would be 
> preferred.

In the end, Cairo really doesn't have a big enough sample size to sort
out these two possibilities clearly. We have basically three places on
the table right now:

cairo_surface_t *
cairo_png_surface_create (FILE                  *file,
                          cairo_format_t        format,
                          int                   width,
                          int                   height);

cairo_surface_t *
cairo_image_surface_create_for_data (char                       *data,
                                     cairo_format_t             format,
                                     int                        width,
                                     int                        height,
                                     int                        stride);

cairo_font_t *
cairo_ft_font_create_for_ft_face (FT_Face         face,
                                  int             load_flags,
                                  cairo_matrix_t *scale);

I think the image surface may have the clearest argument for a
destroy notifier ... creating an image surface for a GdkPixbuf, a
numeric-python array, an Xcursor  image and passing it to some other
portion of code is a very natural operation.

See:

http://lists.freedesktop.org/archives/cairo/2004-December/002328.html

But that is, I think representative in general of why destroy notifiers
are better ....  they don't just work in constrained environments where
an external object references a Cairo object, they work well in when
passing Cairo objects between unrelated portions of code.

Regards,
						Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050126/c1fb3dc3/attachment.pgp


More information about the cairo mailing list