[cairo] Draw outline text
krh at bitplanet.net
Sun Apr 1 09:53:53 PDT 2007
On 3/31/07, Akex J. <jordan2.j at gmail.com> wrote:
> I'm trying to draw outline text fast.
> I'm using code like on this page
> But it's too slow, cairo_show_text() is fast, but the other sample that
> draw outline text ("void") is very slow.
Converting to a path and stroking is the right way to do this, but
you're right it's much slower than the regular text functions. The
difference is that for cairos text functions, cairo caches the glyphs
internally as pre-rendered alpha masks, but when stroking a text path
cairo has to render the entire geometry over and over again.
> Is there any other way to draw (outline) text fast ?
> As I see cairo_show_text and cairo_text_path are "toy" API and
> documentation say I should use cairo_glyph_path(), but I have no idea how.
> Is there any sample or can someone show me how can be done with
> cairo_glyph_path() ?
This is not related to the speed issue. The cairo_show_text function
is a toy API in the sense that it only works for a limited set of
A feature that will speed this up is the user font API that's been in
development for a while, on and off. It allows a cairo application to
provide a new type of font where the application is responsible for
rendering the glyphs. Cairo caches the glyphs that the user font
implementation renders just as for the built-in font types and this
will give you the same performance as the standard text functions.
The outline text effect can be achieved by wrapping a given font in an
outline user font; the implementation delegates to the real font and
then renders the stroked outline and passes it back to cairo.
For now though, the user font feature is just a few patches in the
mailing list archives, but it might happen for 1.6.
More information about the cairo