[cairo] controlling the DPI in libsvg and friends

Carl Worth cworth at cworth.org
Sat Aug 13 02:31:17 PDT 2005


On Sat, 13 Aug 2005 05:11:53 -0400, Jason Dorje Short wrote:
> * libsvg gets a new function, svg_set_dpi.  This function probably needs 
> to be called before parsing the SVG, but I don't see how to check this. 

That seems to be a reasonable requirement, and it shouldn't be too
hard to detect a late call if you really cared to.

> * svg2png is given a new parameter --dpi.  Note that most SVG files 
> (including all created with inkscape AFAICT) will not operate 
> exclusively in distance measurements.  Even if you tell inkscape to use 
> inches as its default unit everything is still saved in pixels. 
> Attached is a simple SVG that is all in inches.  Using --dpi with this 
> does work.  This would be useful for rendering into a resolution for 
> printing (for instance). The -d option is also compatible with 
> inkscape's command-line interface (rsvg does separate X and Y dpi
> setting).

I had made the suggestion of making a file that entirely uses absolute
unit identifiers as you have done here. While this particular file
looks just fine, it was pointed out elsewhere in the thread that this
isn't a suitable solution in the general case since the path data
coordinates cannot accept absolute unit identifiers.

A much more compelling solution is to use absolute unit identifiers on
the top-level width and height attributes, add a viewBox attribute to
set the scaling bounds, and then avoid the use of absolute unit
identifiers throughout the file. Thanks to mental for this solution:

http://lists.freedesktop.org/archives/cairo/2005-June/004378.html

The patch looks fine to me.

-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/20050813/03fde82a/attachment.pgp


More information about the cairo mailing list