[cairo] transforming text

Matt Bartolome mattxbart at gmail.com
Wed Aug 5 10:47:38 PDT 2009


Hi,
I'm drawing in geographic units so I applied a transform and translate
to draw correctly in pixel space. This works fine. When I draw the
text using the same transformation it appears vertically reflected
(this is what I would expect it to do). How would you go about drawing
the text so it doesn't appear flipped, but still in the correct x,y
position and rotation? Attached is a clip of the image I'm getting,
obviously the text is wrong and is what I'm trying to correct.

Hints, pointers appreciated!
Thanks,
Matt

#bounds in geographic units
xmin, ymin, xmax, ymax = max_bounds(sticks)

#scale factor
scale_x = width / (xmax-xmin)
scale_y = height / (ymax-ymin)
scale = min([scale_x, scale_y])

ctx.save()
ctx.scale(scale,scale)
#flip y
matrix = cairo.Matrix(1, 0, 0, -1, 0, 0)
ctx.transform(matrix)
#output from 0,0
ctx.translate(xmin, -ymax)

#draw 2d profile components
ctx = horizontal_center(ctx, sticks)
ctx = stick_head(ctx, sticks)
ctx = surface_elevations(ctx, sticks)
ctx.restore()

#at this point I would like to draw the text somehow with the proper
transform, rotation etc...
ctx = draw_text(ctx,sticks)

surface.finish()


More information about the cairo mailing list