[cairo] simple surface size question
pcjc2 at cam.ac.uk
Tue Jan 20 04:28:39 PST 2009
On Mon, 2009-01-19 at 22:37 -0500, Dan McMahill wrote:
> How do I handle not knowing the x/y limits of my drawing up front?
> fact, unless I do something drastic to the pstoedit driver, I might
> have negative x and y coordinates in my cairo calls. Is that even
> allowed (negative coordinates)?
Negative coordinates are allowed, but unless you've set the scale
matrix, your coordinate system will be in postscript points, *possibly*
with drawing outside your page size being clipped / culled.
Does the EPS backend for pstoedit calculate the bounding-box after, or
I'm wondering if you need to create a "similar" surface to the PDF,
render into that (whilst watching your coordinates to compute the
bounding box), then render from the "similar" surface into the PDF
One of the cairo gurus will be able to better answer this though..
Internally there is a thing called a "meta-surface" which caches the
drawing operations - so you should still get vector output. Calling
cairo_surface_create_similar() on the PDF one will get you a
meta-surface. You have to specify width / height, but I don't think that
Looking at the code, I think the operations you want to get the extents
of a surface (meta or otherwise) are not exposed in the external APIs.
(Cairo even has an "analysis" surface internally, which sounds much like
what you want here - unfortunately not exposed).
There are, however APIs which can compute the extents for various
Hope that is of some help,
Electrical Engineering Division,
University of Cambridge,
9, JJ Thomson Avenue,
Tel: +44 (0)7729 980173 - (No signal in the lab!)
More information about the cairo