[cairo] Pango cairo target surface size

Rob Kramer teegee at gmail.com
Mon Mar 23 19:41:40 PDT 2015


On 03/23/2015 11:43 AM, Lawrence D'Oliveiro wrote:
> On Mon, 23 Mar 2015 11:29:51 +0800, Rob Kramer wrote:
>
>> On 03/23/2015 11:20 AM, Lawrence D'Oliveiro wrote:
>>
>>
>>> 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?
> You use it to measure the text_extents with cairo_text_extents or
> cairo_glyph_extents
> <http://cairographics.org/manual/cairo-text.html#cairo-text-extents>.

Ah, I think you misunderstood my question.. If all I wanted was to 
calculate extents, I could use plain Pango too.

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.

Cheers!

      Rob


More information about the cairo mailing list