Text Alignment
Learn about text alignment in Pycairo.
We'll cover the following...
Text alignment using text extent
We can use the text extents to align text. As an example, we will look at the ways to align text to the left, right, and center. Here is a function that displays a string that is left-aligned to the point (x, y)
:
def left_align(ctx, x, y, text):
ctx.move_to(x, y)
ctx.set_source_rgb(0, 0, 0)
ctx.show_text(text)
This is fairly standard. It sets the current point to (x, y)
, sets ...