No subject


Tue Feb 19 13:30:23 PST 2008


your system bitmap memory? This will only work if your bitmaps are in
the limited set of pixel formats cairo deals with, which pretty much
means 4-bytes-per-pixel RGB or ARGB.

If you have more variation than that then you'll want to implement a
surface backend. Take a look at one of the existing ones. There's lots
of methods you can implement to make things go faster, but the there is
a minimum that will get you all rendering in software and is enough to
confirm that things work:

    _create_similar
    _finish
    _acquire_source_image
    _release_source_image
    _acquire_dest_image
    _release_dest_image
    _get_extents

You also need a system-specific function that will create your surfaces
based on some set of system-specific arguments. Something like
cairo_xlib_surface_create.

> But for the font support in Cairo library, I don't know how to
> integrate Brew's font with Cairo. Anyone can advice me of anything to
> begin with?

Font backends aren't as simple as surface backends. You need to be able
to provide two things - a font "face", which is an abstract
representation of the font, and then a "scaled font" implementation
which is essentially the face plus some set of transformations to
produce glyphs.

At minimum, you need to be able to get (or derive) the metrics of an
entire font and a single glyph, and be able to generate image surfaces
using glyph bitmap data.

If you want to implement the "toy" interface (cairo_select_font_face)
you'll also need to provide a way to create a face/font from a name. If
your system is any kind of sane there'll be a nice way to do it. If its
insane like mine, you'll have to search the filesystem :(

As simpler examples, I offer my surface and font backend implementation
for AROS, which are here:

  http://cataclysm.cx/git/cgit.cgi?r=cairo/tree/src/cairo-aros-surface.c
  http://cataclysm.cx/git/cgit.cgi?r=cairo/tree/src/cairo-aros-font.c

They're probably not the best examples but because I'm the only user and
I haven't implemented any system-supported stuff, you might find them
easier to follow as you get started. I'm still very new to cairo though,
so if you're in doubt check one of the real backends as at least we know
they're done correctly :)

Do let us know how you get on!

Cheers,
Rob.


More information about the cairo mailing list