On 18-Sep-2014 10:25, LucaDC wrote:
mathog wrote
<svg width="8.5in" height="11in" viewBox="0 0 816 1056"> After some consideration it seems to me that the viewbox coordinates should come out to 96dpi no matter what the physical length units are.
I don't agree. I see no valid reason not to use:
<svg width="8.5in" height="11in" viewBox="0 0 8.5 11"> so all the numbers in the document are going to automatically be in inches and hence very frequently needing only few digits after the dot. Inkscape does not need to know what the numbers it's crunching mean in the physical world, but the user may appreciate having them written inside the file (I do). Please, share your "some consideration". Thanks.
96 dpi was a mistake, that should have been 90. 90 was what Inkscape did before this units work started (and still does if one creates a new drawing and doesn't change the default units). Create a document, draw a rectangle in it, and save it and it will say this:
viewBox="0 0 744.09448 1052.3622"
with no inkscape:units value.
The concept of "all the numbers in the document" being in inches is not generally possible. Long story short, if somebody hands you an SVG file and you read in some part of it:
<rect x="5" y="5" width="3.9" height="1.9"/>
the only way to know that those are inches is to traverse all the way back up the tree, taking each and every transform into account, to get the final numbers. They will only be in inches if the total scaling after all of those transforms is 1:1, which is not generally the case. On a unit change the current code enforces the "only unitary transform" constraint by traversing the tree, changing all of the coordinates and lengths. Which breaks things, because it does not enter defs, so references to defs fall in the wrong places or at the wrong scales. (Sorry to keep harping on this, but these unit related defects keep breaking working code elsewhere in the program. For instance, clipping and pattern fills.)
I guess what really mystifies me is why anybody cares what the numbers look like in the raw SVG. It may be a text file, but that does not mean it is intended for human (end user) consumption. Human interaction with an SVG should be through a viewer (for passive consumption), or an editor (like Inkscape, for composition). So why does it matter if the user units are px, inch, or mm? Are you extracting text from the raw SVG for other purposes, or is the GUI having problems representing the values, in some way, for some unit settings?
Regards,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech