[cairo] Cairo/FreeType integration [Advanced]

Ian Britten britten at caris.com
Tue Oct 7 13:05:38 PDT 2008

Hi all,
Could someone give me some guidance about how I might best proceed
to integrate Cairo into an existing FreeType-using framework, or
whether it's even possible.
[ In other word, at a fairly low-level ]

We have an existing framework that is heavily-dependent on FreeType,
ICU, etc for rendering text.  We have basically implemented our own
rasterization engine, which receives FT_Face and FT_Glyph
information, and ends up using FT_Outline_Decompose(),
FT_Outline_Render(), etc, to render the text.  Our toolkit-specific
'canvases' plug custom callbacks into the various FT hooks
(moveTo(), lineTo(), etc) which end up rasterizing the text
instructions into the appropriate type of bitmap and copying them
to the screen, or write them to the file (PS), etc, as instructed.

So, our existing framework takes care of finding+loading the various
font faces, handles the glyph-caching FT provides, uses ICU to kern
the text, etc.  I don't need to 'get' anything from Cairo, as we
already have solutions for getting covers, sizes, etc.

At the point I'm trying to integrate Cairo into all this, I
basically have an FT_Face, an FT_Glyph, (X,Y) position, angle, etc,
I'm just not sure if I can make use of all that, with the existing
(public) interfaces from Cairo.  For example, when looking at
http://www.cairographics.org/manual/cairo-FreeType-Fonts.html, I
don't see any way to work with an existing FT_Glyph...

Now, obviously I'm glossing over a lot of high-level details, but
anyone familiar with FreeType should get the gist of what we're
doing.  I'm assuming that there must be some viable approach,
since I'm guessing what I'm looking to do is similar to what
frameworks like Pango end up doing.  I'm just not sure where to
look, if there is a 'deeper' (Internal?) Cairo interface for

Otherwise, my only approach seems to be rasterize the text myself
and just draw images to Cairo.  However, this seems
less-than-optimial in some cases, such as rendering text to PDF.

Any guidance/pointers/suggestions welcome!

More information about the cairo mailing list