Document and Object Units

I have now implemented pages sizes using real world units as well as document units using a viewBox as described in my previous post. Although it is mostly working, there are a few known bugs when changing the document unit, namely connectors and 3d boxes do not scale properly. I have also worked on fixing regressions introduced by the phase one unit refactor.

Besides document-wide units, it is also useful to have object specific units for convenience. As real world units are handled as scaling factors of the document unit by the SVG specification, they are only recommended for the document size, not individual objects, and their values are counterintuitive when a viewBox is used to specify document-wide units. Therefore, I’ve decided to implement object specific units using an inkscape:unit attribute instead, which will also allow for units not defined in the SVG specification, e.g. feet. The manner in which object sizes and positions are written to a SVG file will not change; the attribute will only be used to remember which unit should be displayed when an object is selected in the Inkscape UI.

Choosing the appropriate unit to display is trivial when only one object is selected or multiple objects are selected with the same unit—display the object’s or objects’ unit. Things become more complicated, however, when objects with different units are selected. Either the unit selector can be left to keep its current unit, the document unit can be displayed, or the most common unit can be displayed, chosen arbitrarily when two or more units are equally common. I think leaving the unit selector alone is the most intuitive solution but am open to suggestions. When objects are deselected, the unit selector will return to its previous unit, unless the unit was manually changed while the objects were selected in which case it would retain its unit.

This entry was posted in and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.