
On 12-Sep-2014 09:32, Tavmjong Bah wrote:
The example:
<svg width="100mm" height="100mm" viewBox="0 0 100 100">
Is insufficient. Must the numbers in the viewBox match those in the width? In other graphics formats that isn't the case (see below). Can't tell from this svg example. The example could be more like this (for A4 paper):
<svg width="210mm" height="297mm" viewBox="0 0 2100 2970"> <g style="fill:#ff0000;stroke:none" > <g transform="scale(2)"> <rect x="10" y="20" width="50" height="100" /> <rect x="250" y="350" width="25" height="50" /> </g> <rect x="200" y="300" width="250" height="500" /> </g> </svg>
NOW, what happens if the user changes units from mm to in? If this was Microsoft's EMF format after that change the equivalent would be:
<svg width="8.267in" height="11.692mm" viewBox="0 0 2100 2970"> (no other change)
See for instance the description of the metafile header here:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd162607%28v=vs.85%2...
where the drawing resolution is set by szlDevice and its physical size by szlMillimeters. They later added szlMicrometers for better precision on the latter, although in most files one encounters they differ by only a perfect factor of 1000. (Further on in the file it is commmon to run into other transforms including some mapping viewports onto windowextents.) The EMF format does not worry about what happens if a program chooses to show the physical units in inches instead of mm, that isn't anything it cares about. All it cares about is the internal precision and the physical size, with the latter always being in metric units. That said, there is a "SETMAPMODE" record in which the internals of the drawing can be in inches or "twips". However, documents that actually use these other modes are exceedingly rare.
Back to SVG. If the numbers in the viewBox need not match the numbers in the width/height, there is an implicit transform at the top of the SVG document, which converts from arbitrary internal units to defined external physical dimensions. If they must match then there is no such transform - and the reader needs to see how that plays out too. Explicitly.
Regards,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech