[cairo] Creating an image with text
behdad at behdad.org
Thu Apr 29 01:21:18 PDT 2010
On 04/28/2010 09:23 AM, Oscar Lazzarino wrote:
> I'd like to build an image containing some text.
> Problem is, I don't know how big the image should be, until I can
> compose the Pango Layout
> But I can't create the pango layout without a cairo context.
> And I can't create a cairo context without an image surface.
> But I don't know how big the surface shoud be
> [ ad libitum ]
> Any hints?
Typically what I do is:
- Create a surface sized 0 by 0
- Call my pango rendering function that would render to the surface and
return the size
- Create a new surface of the desired size
- Call the rendering function again, with the new surface.
More information about the cairo