Inkscape Units Identifier Tests and Conclusions

Last updated 24 Nov. 2016

This page collects together a series of unit identifier dependent tests and makes some conclusions based on the tests.

For background and definitions see: Units in Inkscape wiki page.

Basic Units Identifier Tests

External unit identifiers are determined by the unit identifier in the SVG root 'width' and 'height' attributes.

Scale is determined by the viewBox dimensions in relationship to the SVG root 'width' and 'height' attributes. For example if the 'width' is '1in' and the viewBox is '0 0 90 90' the scale would be 90 'user units' per inch.

Patch 1 changes guides and 3d boxes to use 'user units'.

Patch 2 is my proposal for handling the transition from 90 to 96 dpi in 0.92.x.

Guides and Grids

Each test represents a 20mm x 20mm square including:

Tests

3D Box Tool

Note: There is a bug in Inkscape that sometimes displays a box shifted in 'y' from its proper place. Nudging the box will move it to its proper place.

Conclusions

From the various tests above:

  1. Use of unit identifiers in SVG root 'width'/'height' mandate use of 'viewBox' or display will be different between 0.91 and 0.92. Fixing SVG's with unit identifiers in 'width'/'height' and no 'viewBox' could be done by adding an appropriate 'viewBox'. (Lengths in terms of '%' are not corrected properly but Inkscape never creates such files.) -> Add 'viewBox' to all templates. PARTIALLY DONE.
  2. Use of unit identifiers in SVG root 'width'/'height' with 'viewBox' results in correct rendering in both 0.91 and 0.92. -> Add 'viewBox' to all templates. PARTIALLY DONE.
  3. Grid, guides, and 3D box tool need fixing between 0.91 and 0.92. If there is a 'viewBox', at least guides can be handled by using a 'scale' determined from 'width'/'height' and 'viewBox'. Should also be possible with grids. -> Add code to adjust guides and grids based on 'scale'. Code in trunk for guides and 3D Box tool. NEEDS BACKPORTING FOR 0.91.
  4. Use of "inkscape:document-units" should be limited to the GUI. There are about 50 places where "inkscape-document-units" is used in the codebase. DONE.
  5. The 'units' attribute in 'namedview' should be renamed to better indicate its purpose. DONE (Changed to 'page-size-unit;).
  6. The use of 'pt' as default unit identifier should be change to 'px'. Non-pixel units should not be used except possibly in the root 'width'/'height' SVG element. Change default unit identifier to 'px'. DONE.
  7. It is possible to use 'pt' for 'font-size' via a preference (Text->Text Size). -> Disable ability to use 'pt' or other unit other than 'px'. DONE.
  8. The 'Rect' tool displays values in the 'rectangle's coordinate frame which includes transforms while the 'Select' tool displays values in the document's coordinate frame. See #1384915. -> Out of scope.
  9. Changing document units at this point (0.91) needs disabling. There are too many places where things can go wrong (see bugs listed in Document Unit Change wiki page). -> Disable unit changing in Document Preferences. DONE.

Other Actions

  1. Backport r13632 from trunk to fix an accuracy bug. (See: #1384915.) DONE.
  2. Investigate adding an "inkscape:dpi" attribute to track 90 vs 96 dpi. Use this value to in PostScript/PDF export.
  3. Investigate not overwriting inkscape version until saving/export.

Specialized Tests

For testing changing document unit: