[cairo] Cairo/FreeType integration [Advanced]
Behdad Esfahbod
behdad at behdad.org
Wed Oct 8 20:23:13 PDT 2008
Ian Britten wrote:
> Hi all,
Hi,
> 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 ]
>
> <Background>
> 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.
> </Background>
>
> 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...
Cairo's FreeType integration is at the level of FT_Face and glyph indices. No
FT_Glyph involved.
> 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
> this.
Pango uses the above-mentioned API. You should not need to handle FT_Glyph's
yourself. If you need metrics, use cairo API for that too.
> 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.
Indeed.
> Any guidance/pointers/suggestions welcome!
> Ian
Hope that helps,
behdad
More information about the cairo
mailing list