[cairo] Pango cairo target surface size

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Sun Mar 22 20:43:26 PDT 2015


On Mon, 23 Mar 2015 11:29:51 +0800, Rob Kramer wrote:

> 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?

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>.


More information about the cairo mailing list