[cairo] Text on a rotated context?
Ian Britten
britten at caris.com
Wed Nov 12 10:22:51 PST 2008
Hi all,
I'm drawing text to a (PDF) surface/context, via calls to:
cairo_set_font_matrix()
cairo_show_glyphs()
In most cases, this seems to be working as expected. (Yay!) :)
However, it seems that if my Context has a rotation angle set in
it (So as to rotate the entire drawing), that angle is not obeyed
when drawing text (Or, that it the impression I get from looking
at my output).
I generate two separate PDFs, one at 0 degrees, and one at 45
degrees.
- In the rotated one, all the lines/polygons/etc are all rotated
as I would have expected. This didn't require me to add any
extra code to my line/polygon rendering code - I just passed
down my user units, and they came out rotated (Yay!)
- The text in both drawings came out at exactly the same (device)
positions, which obviously looks wrong for the rotated case.
It's as if the rotation of the Context was ignored. The
characters are all upright (Instead of rotated), and when I
overlay the two PDFs, the text seems to have been drawn at the
same device positions. (It was drawn at the same user positions)
[ I can post some screenshots/PDFs if it'd help to clarify this ]
Not knowing anything about the Cairo internals, I did some
grep'ing, and ended up in _cairo_gstate_transform_glyphs_to_backend()
which seems to only use parts of the matricies, but I confess, I
have no idea if I'm looking at relevant code...
Irregardless, my question is:
Does the Font Matrix (and the user positions I pass to
show_glyphs()) simply build on top of whatever matrix is set up
in the Context, just like all my other drawing calls?
It seems like maybe I'm responsible to propagate parts of my
Context matrix into my Font matrix (ie: The angle), and to compute
all the rotated positions myself, which seems wrong (to me).
Can anyone confirm or reject this premise? Or, provide any
insight into the results I'm seeing?
Thanks for any info/pointers/solutions!
Ian
More information about the cairo
mailing list