[Cairo] Graphite API needs

Carl Worth cworth at east.isi.edu
Mon Aug 25 08:18:29 PDT 2003

On Aug 22, Sharon_Correll at sil.org wrote:
 > Graphite was originally developed on Windows but we're just on the verge of
 > completing a port to Linux, so we're interested in developments like Cairo
 > that we might be a good fit with our efforts.

Hi Sharon,

I'm glad you're looking at Cairo. I hope it will work for what you

As I'm sure you've seen from the mailing list traffic, good text
support for Cairo is in the planning stages, (but hasn't been
implemented just yet).

 > It appears that in relation to Cairo, Graphite would be a level just above,
 > and would use Cairo's text API to do the actual drawing. And also to obtain
 > glyphs metrics for its glyph-layout process. Does that sound right?

Yes, Graphite would sit just above Cairo, but Graphite would likely
also need to reach around Cairo into the native font system
(eg. freetype) for some font metrics.

 > (1) getting the font's em-square (in rendered units)
 > (4) getting a glyph's outline in rendered units (or at least a specific x/y
 > I assume cairo_text_extents would handle (2). But I don't think I see
 > anything in your API to handle (1) or (4).

There has been a conscious decision in the design of the Cairo text
APIs to not try to abstract away all details of the underlying font
system. There's a complex interface there that differs between
operating systems, so there's no easy way to support everything needed
while still being able to maintain a clean API for Cairo.

Inside, the compromise plan is to support basic text functionality
with a portable API, and to require sophisticated users of text to
call directly into the underlying system-specific font support.

With that approach, on Linux, you could use fontconfig to find your
fonts, use Freetype APIs to get the metrics you need, then pass the
FT_Face object to a cairo_font_create function in order to use Cairo
to display text in the font.

Does that seem like a reasonable approach?

 > (7) inverting a rectangle in order to draw a selection or cursor
 > (I don't see anything specifically along the lines of (7) either,
 > but we could probably do this a different way.)

Inverting foreground/background colors is a common operation for text,
but it doesn't fit in well with Cairo's rendering model. You'll
probably just have to fill the shape you want as a path for the
background color and then draw the text on top of it.


More information about the cairo mailing list