width = 500
height = 500
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height)
ctx = cairo.Context(surface)
ctx.set_source_rgb(1, 1, 1)
rect(ctx, (0, 0), (width, height), stroke=False)
ctx.set_source_rgb(0, 0, 0)
for i in range(5):
    for j in range(5):
        x = 100 * i + 20
y = 100 * j + 20
theta = math.pi * 0.25 * (5 * i + j)
text(ctx, 'hello world', (x, y), theta, font_size=15)
surface.write_to_png('text-demo.png')
повернуть текст вокруг его центра в pycairo