[cairo] Rendering text into fixed-size grid cells
behdad at behdad.org
Sat Jul 3 08:21:29 PDT 2010
You've got quite some code to write then...
Essentially what you want to do is to use cairo_show_glyphs(), so you can
position multiple glyphs in one call. To get the glyph indices, you use
cairo_scaled_font_text_to_glyphs() and cache the results. If you pass one
character to that function, it always returns one glyph currently, so you can
make that assumption...
Something like this, but more complex, is implemented in vte for rendering
terminal contents using pangocairo:
On 07/03/2010 05:51 AM, Cxx Joe wrote:
> 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... 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.
>  http://code.google.com/p/infekt/source/browse/trunk/src/lib/nfo_renderer.cpp?spec=svn204&r=188#567
> Thanks in advance!
> cairo mailing list
> cairo at cairographics.org
More information about the cairo