[cairo] svg_cairo_get_size problem

Carl Worth cworth at cworth.org
Fri Jun 24 11:21:16 PDT 2005


On Fri, 24 Jun 2005 13:49:58 -0400,  wrote:
> Since SVG paths cannot be specified in anything but px, in practice
> the "same units as the rest of the drawing" must always be px.

Wow, I never realized SVG has that limitation. That's actually quite
surprising to me, (but the BNF for path data does confirm that). And
it's not much of a restriction, user-space units are preferred for
drawing anyway.

> If you need constant-sized documents without changing contents, you
> can specify the dimensions in real-world units and use viewBox to
> force a specific "effective DPI".
> 
> e.g. for a 3in x 2in document at 100dpi:
> 
>  <svg width="3in" height="2in" viewBox="0 0 300 200">...

That's a very good approach, and would be a better way to fix the
files we have been discussing.

> Note that viewBox doesn't really change the DPI, it just applies a
> scaling transformation.  So while px will now render at consistent
> physical size, other absolute units will no longer do so.

Right. So absolute units really shouldn't be used unless you really
know why you're using them. Note the following paragraph in the
SVG specification:

	Note that use of px units or any other absolute unit
	identifiers can cause inconsistent visual results on different
	viewing environments since the size of "1px" may map to a
	different number of user units on different systems; thus,
	absolute units identifiers are only recommended for the width
	and the height on outermost 'svg' elements and situations
	where the content contains no transformations and it is
	desirable to specify values relative to the device pixel grid
	or to a particular real world unit size.

-Carl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050624/8a5a2fe7/attachment.pgp


More information about the cairo mailing list