[cairo] Horizontal Text

Behdad Esfahbod behdad at behdad.org
Thu Aug 6 07:11:47 PDT 2009


On 08/06/2009 05:08 AM, Matthias Hilbig wrote:
> Hi,
>
> I want to layout text horizontally even if the underlying diagram is
> rotated. And if I zoom into the diagram, the text should also scale.
>
> Can I somehow calculate the scaling factor from an arbitrary affine
> transformation?

Yep, it's not rocket science.  The code in 
_cairo_matrix_compute_basis_scale_factors() in cairo-matrix.c does that for 
example.

You may need to detect rotation first. That's not hard either.  In general, 
all the tricks work by transforming the unit vector (1,0) or (0,1) to the 
other space and analyse the result.  You can atan2(x,y) on the result to get 
the rotation of the X basis for example.

Hope that helps,
behdad


> Regards
> 	Matthias


More information about the cairo mailing list