[cairo] Re: cairo internal design ideas

David Reveman c99drn at cs.umu.se
Wed Sep 22 20:14:54 PDT 2004

On Tue, 2004-09-21 at 07:39 -0400, graydon hoare wrote: 
> On Tue, 21 Sep 2004 12:56:21 +0200, David Reveman <c99drn at cs.umu.se> wrote:
> > The reason to why I'd like a different backend function for glyphs is
> > that this would allow surface backends to ask a font backend for a
> > specific representation of the glyphs. Possible scenario: a font backend
> > could be able to provide three different glyph list representations, a
> > list of image masks (would provide rendering to all types of surfaces),
> > XGlyphElt's for use with XRender and some glyph list that a native win32
> > surface backend could use.
> I am part way through a patch (this week) which does something like this. so
> on the glyph front I agree with your suggestion. I haven't worked on the
> vertex / trap code much so I don't know the issues. my patch is more or less
> as follows (deriving from a conversation keithp and I had on friday):
>   - a generic glyph cache object type is added, which maps glyph keys
>     ([font,matrix,glyph] tuples) to void* and performs resource and
>     lifecycle management for the entries. caches are parameterized by
>     some constructor and destructor functions.
>   - surfaces own glyph caches, not fonts, and generally all surfaces using
>     a given backend share one (or a small number) of such caches. in the
>     case of xlib, there is one cache per display; the cache corresponds to
>     a GlyphSet and holds [XGlyphInfo,Glyph] pairs.
>   - glyph caches hold references to fonts in their entries. fonts thus die
>     when users drop all references *and* all cache entries are flushed.
>   - there is a "global" glyph cache which stores an entry type that contains
>     cairo_image_surface_t objects and metrics, from which any backend can
>     pick up glyph images and metrics. fonts are responsible for filling in
>     the global glyph image cache, and indeed fonts make *requests* against
>     the global glyph image cache in order to recalculate their metrics, when
>     asked (in a surface-independent way).
> the hope is to get this working in a manner similar to Xft. we'll see how
> close is possible.

ok, it's good to see that someone is doing some work on this.

The things you've described here are all part of the font backend and I
haven't done a huge amount of thinking about exactly how that would work
but I guessed it would be something like this. I think that all this
would work very well with the surface glyph interface I suggested.

More information about the cairo mailing list