The SVG root element currently declares width/height as unitless integers
rounded up with ceilf():
<svg width="106" height="56" version="1.1" ...>
This (a) loses the exact symbol dimensions, as with the EPS bounding box, and
(b) leaves the physical size undefined: unitless values are CSS px at 96dpi,
so an SVG and an EPS of the same symbol have different physical sizes when
placed in layout software.
The attached patch (against current master 94fdc846) outputs instead
<svg width="37.29mm" height="19.47mm" viewBox="0 0 105.7039 55.1905" version="1.1" ...>
for zint -b EAN13 -d 501234567890 --scalexdimdp=0.33mm,72dpi -o out.svg:
viewBox with the exact dimensions in Zint units (4dp), andwidth/height in mm using the same "1 unit = 1 point" convention as theThis changes behaviour: browsers now render the SVG at its physical size
instead of in px (here 37.29mm instead of 106 CSS px, about 28mm on a nominal
96dpi screen). If that is a concern for backwards compatibility, the mm
dimensions could be made optional via an output option, keeping exact
fractional px plus viewBox as the default. Happy to rework the patch in that
direction.
The patch also contains the required test adjustments: regenerated expected
files in backend/tests/data/svg (test_svg -g), the PRINTF fail-injection
count in test_svg test_fm (the header is now written with fm_putsf()
instead of fm_printf()), and the expected SVG in backend_qt test_qzint
saveToMemfileTest. test_svg (1747 assertions), test_emf and test_qzint
(103 tests) pass.