[cairo] Pango cairo target surface size
behdad.esfahbod at gmail.com
Tue Mar 24 12:00:02 PDT 2015
On 15-03-23 10:41 PM, Rob Kramer wrote:
> What I want to do is paint a string to a surface the same size as the text's
> logical extents -- without doing the text layouting twice (once to calculate
> the extents, once to paint). Since I cannot change the target image size after
> it is set, or import an existing Pango layout into Cairo, I wondered whether
> anyone on this list would know of a method.
You create a 0x0 surface, create PangoLayout for it, measure, create new
surface & cairo_t, and render the same PangoLayout to new cairo_t.
PangoLayout caches layout internally and if font size, options, etc don't
change, it won't recompute layout.
Now that you mention it, pango-view itself doesn't try to do this. It does
layout twice. Maybe I'll fix that.
More information about the cairo