Skip to content

Fix unit conversions for uutounit and unittouu

Jonathan Neuhauser requested to merge joneuhauser/extensions:fix-units into master

The root cause of #367 (closed) is a misunderstanding what "user unit" means. The spec is quite clear on this:

One px unit is defined to be equal to one user unit. Thus, a length of “5px” is the same as a length of “5”.

Previously, unittouu converted to whatever unit is used in the width/height attribute of the toplevel SVG. This is wrong. The width/height attributes is an outward-looking attribute and does not influence the relative positioning of elements. If the viewBox is a camera moving over the canvas, the width/height attributes are the the physical size of the monitor connected with that camera.

I'd rather let the documentation I've written explain this crucial difference.

https://joneuhauser.gitlab.io/-/extensions/-/jobs/1300144417/artifacts/build/sphinx/html/units.html

There is nothing wrong with asking "what is the physical width of a given object on this monitor" (unit to page units? idk) and this would make sense for some export extensions. But this is not what user unit means, and gives inconsistent results, see original issue.

Edited by Jonathan Neuhauser

Merge request reports