Units In Inkscape

From Inkscape Wiki
Revision as of 16:24, 12 September 2014 by Tavmjong (Talk | contribs) (Created page with "=Introduction= This page documents the philosophy for Units handling inside Inkscape. Units are not as straight-forward as one should think they are. =Historical View= Part...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

This page documents the philosophy for Units handling inside Inkscape. Units are not as straight-forward as one should think they are.

Historical View

Part of the problem with units in SVG and CSS in general is why they are there in the first place. In the early days it was assumed that one would want to display drawings on a screen at full scale. In otherwords, a "one inch square" would be display on a screen as a physical one inch square. This required that displays be queryable as to what there true DPI was. Display manufactures rarely provided the means to query the DPI of the display, and when they did, they often returned incorrect results. Thus, the use of "real" units never became popular and in reality is usually not what one wanted. Eventually, after long arguments, the CSS working group dictated that one inch would be fixed to 96 pixels regardless of screen resolution (ironically, with so called Retina displays, there is once again interest in scaling drawings based on DPI).

The Philosophy

Absolute units should not be used inside an SVG file with one exception:

The root width and height may have units, which with a proper viewBox determines an appropriate scale for a drawing. (This sets the "real" world value of the SVG user unit.) This reflect the opinion of the majority of the SVG working group.

It should be noted that the relative units em, ex, and % can be useful in some cases.

Inkscape & Units

Inkscape should not write out absolute units other than in the root SVG element. Inkscape must, however, be able to interpret units from non-Inkscape produced files according to the CSS defined value of 96 pixels (initial user-units) per inch.[1]

The use of units in the Inkscape GUI is for ease of authoring only. The actual values should be stored as user-units.

Changing the Inkscape Document unit should not introduce any transforms on elements nor should changing the SVG root width/height or the viewBox.

The GUI should show sizes taking into account both the Inkscape Document unit as well as the choosen GUI unit, taking into account the width/height and viewBox.

For example:

<svg width="100mm" height="100mm" viewBox="0 0 100 100">

describes a drawing 100mm x 100mm where one user-unit is equivalent to one "mm".

The Inkscape property inkscape:document-units should be set to "mm".

(Question, why do we have this property? Can't it be determined from width and/or height?)

If the GUI unit is set to "mm" then the GUI would show a width of '25.4' for a rectangle 25.4 user-units wide. If the GUI unit is set to "in", the GUI would show '1.0'.

A 2013 GSoC project by Matthew Petroff unified the Units handling in Inkscape, mostly implementing this philosophy. Inconsistencies should be viewed as bugs.

Notes

The outer SVG width/height, viewBox, and document-units should not be changed in the XML Editor. Use the Page tab of the Document Properties to change the document size or document unit to avoid the risk of them becoming inconsistent.