ScaledFont.textExtents

void textExtents(string utf8, out cairo.types.TextExtents extents)

Gets the extents for a string of text. The extents describe a user-space rectangle that encloses the "inked" portion of the text drawn at the origin (0,0) (as it would be drawn by [cairo.context.Context.showText] if the cairo graphics state were set to the same font_face, font_matrix, ctm, and font_options as scaled_font). Additionally, the x_advance and y_advance values indicate the amount by which the current point would be advanced by [cairo.context.Context.showText].

Note that whitespace characters do not directly contribute to the size of the rectangle (extents.width and extents.height). They do contribute indirectly by changing the position of non-whitespace characters. In particular, trailing whitespace characters are likely to not affect the size of the rectangle, though they will affect the x_advance and y_advance values.

Parameters

utf8a NUL-terminated string of text, encoded in UTF-8
extentsa #cairo_text_extents_t which to store the retrieved extents.