[cairo] Rendering text into fixed-size grid cells

Cxx Joe cxxjoe at googlemail.com
Sat Jul 3 02:51:25 PDT 2010


I'm looking for the fastest way to render a bunch of text lines into a
grid. Here are some more details:
The grid has a fixed number of lines and columns. Each cell of the
grid is of fixed size (e.g. 10x15 px).

Now what I want to do is render one character into each cell,
preferably somewhat centered inside the cell.
Right now, what I'm doing is enumerate through all characters, then
call cairo_move_to and cairo_show_text[1]... which most probably is a
horrific thing to do. I assume there's a smarter (and faster!) way to
achieve the same results using cairo_show_text_glyphs.
Unfortunately, I'm not quite sure how exactly that smarter way would
look like, so I'm asking for some guidance/poking in the right
direction here :)

I'd like to avoid pango because it heavily relies on glib which adds
quite a lot of overhead.

[1] http://code.google.com/p/infekt/source/browse/trunk/src/lib/nfo_renderer.cpp?spec=svn204&r=188#567

Thanks in advance!

More information about the cairo mailing list