viewBox should be mandatory in default.XX.svg files (experimental branch)

Bug #1385521 reported by Alvin Penner on 2014-10-24
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Undecided
Alvin Penner

Bug Description

as a follow-up to Bug 1384915, some default.svg files from the experimental branch were tested to see if they generated numerical error during loading, or switching default units, or switching document size. The files default.svg and default.en_US.svg passed the test, the file default_px.svg failed, apparently because it does not have a viewBox.

The file default_px.svg from experimental was tested in the main branch code. Initially it loaded as a custom page size due to the fact that the dpi has been changed. This was fixed by correcting the numbers for width and height to make them compatible with trunk code. The page size was then recognized correctly as A4 size. However, there were numerical errors present after switching from A4 to Letter. The resulting viewBox was:
viewBox = "0 0 765 990.00002"
where the height should have been 990 exactly. Since this file did not have a viewBox, one was then specified explicitly, as an exact duplicate of the width and height variables. This fixed the problem of round-off error caused by toggling units or page size.

I would recommend that the same be done in the experimental branch for files like default_px.svg which do not have a viewBox. The reason that this matters is because the variables width and height are single-precision variables while viewBox is a double-precision variable. If the viewBox does not exist in the original svg file, then the sequence of events will be as follows: a very precise string will be read into width and height and rounded off a great deal. This rounded off value will then be transferred to the viewBox which will now be imprecise forever. The round off can be prevented by specifying the viewBox explicitly in the svg file.

su_v (suv-lp) on 2014-10-24
tags: added: precision templates viewbox
Changed in inkscape:
milestone: none → 0.92
Alvin Penner (apenner) wrote :

fix committed to rev 13649

the files default_px.svg and default_pt.svg were modified

Changed in inkscape:
status: New → Fix Committed
assignee: nobody → Alvin Penner (apenner)
Bryce Harrington (bryce) on 2017-01-10
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers