[cairo] Pango cairo target surface size

Rob Kramer teegee at gmail.com
Sun Mar 22 20:29:51 PDT 2015


On 03/23/2015 11:20 AM, Lawrence D'Oliveiro wrote:
> On Mon, 23 Mar 2015 10:46:11 +0800, Rob Kramer wrote:
>
>> I would like to create a cairo image surface that is equal to the
>> logical extents of a text string. This seems to be a chicken-and-egg
>> problem, since I need a cairo_t with surface before I can use layout
>> functions (and the surface size isn't known yet).
> That’s easy. You can create an ImageSurface with 0 width and 0 height,
> put a cairo_t on top of that, and do your text measurements without
> any drawing taking place.
But how does that result in an image surface equal to the extents of the 
string?

My eventual image surface would be created by 
cairo_image_surface_create_for_data(), so that I can paint the string 
bitmap to a SDL2 texture.

  - Rob


More information about the cairo mailing list