Text Extents
Explore how to calculate and interpret text extents in Pycairo, including the bounding rectangle and offsets. Understand how text positioning works relative to the baseline and how to use these metrics for precise text layout in vector graphics.
We'll cover the following...
We'll cover the following...
What are text extents?
The font size gives us control of the nominal size of the font. The text extents tell us the exact size of a particular text string, when rendered with the current font. To be precise, they pinpoint the rectangle around the area that will be marked when we paint the text.
The Context and text_extents functions return a Pycairo TextExtents object (which behaves much like a tuple). Here is an example of this:
xbearing, ybearing, width, height, dx, dy = ...