Re: how to get text size ?
Lawrence D'Oliveiro <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Organization | Geek Central |
| Message-ID | <[email protected]> |
On Sat, 9 Jul 2016 14:48:12 +0200, Enrico Weigelt, metux IT consult
wrote:
> But I'm still struggling w/ the exact meaning of y_bearing ...
There are 6 fields in a cairo_text_extents_t
<https://www.cairographics.org/manual/cairo-cairo-scaled-font-t.html#cairo-text-extents-t>:
the first 4 define the bounding box of the text, relative to the initial
drawing position. To construct the rectangle equivalent
<https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-rectangle-t>,
do it like this:
cairo_text_extents_t text_extents;
cairo_rectangle_t text_bounds;
cairo_text_extents(ctx, "some text", &text_extents);
text_bounds.x = text_extents.x_bearing;
text_bounds.y = text_extents.y_bearing;
text_bounds.width = text_extents.width;
text_bounds.height = text_extents.height;
The other 2 text_extents fields (x_advance, y_advance) define the
offset from the initial drawing position to the final drawing position.
--
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo