roelj / inklingreader

A GNU/Linux-friendly version of the Wacom Inkling SketchManager.
GNU General Public License v3.0
50 stars 16 forks source link

Use viewBox in SVG exports #27

Closed su-v closed 10 years ago

su-v commented 10 years ago

SVG documents with page size in real units should use a viewBox attribute to define the scale, e.g.

   width="744.09448"
   height="1052.3622"
   viewBox="0 0 744.09448 1052.3622"

or

   width="210mm"
   height="297mm"
   viewBox="0 0 744.09448 1052.3622"

or

   width="210mm"
   height="297mm"
   viewBox="0 0 210 297"

The last one redefines the SVG user unit for the document as 1mm, the other two match an A4 page based on (Inkscape's current) 90dpi internal resolution for the 'px' SVG user unit.

While current stable Inkscape never adds this attribute itself to new documents, this has changed in inkscape trunk (for upcoming major release 0.91), and should probably be used in the SVG files exported by inklingreader too (otherwise the documents might render differently in different SVG viewers).

See also: http://www.w3.org/TR/SVG11/coords.html#ViewBoxAttribute

… and for example two recent discussions on the inkscape-devel mailing list (since improved viewBox support is part of the unit refactoring which landed in Inkscape trunk last year): http://thread.gmane.org/gmane.comp.graphics.inkscape.devel/43281 http://thread.gmane.org/gmane.comp.graphics.inkscape.devel/43430

roelj commented 10 years ago

Which variant do you propose to use in InklingReader?

xuv commented 10 years ago

I'd go for second or third, as it comes from a real drawing on paper, where mm units make sense.

roelj commented 10 years ago

I went with the second. Using the mm sizes for both doesn't play nice with librsvg, so I used a constant to calculate the correct value.