Two related precision issues in EPS output (backend/ps.c), patch attached
(against current master 94fdc846).
1. Integer bounding box
The DSC-mandated %%BoundingBox must be integral and is rounded up with
ceilf(), so it can overstate the symbol size by up to nearly 1pt (~0.35mm).
Layout applications (InDesign, Illustrator etc.) use the declared bounding box
as the placed size, so a barcode placed at its natural size comes out slightly
larger than the actual vector dimensions.
The patch adds a %%HiResBoundingBox line with the exact dimensions (4dp,
via fm_putsf()) directly after the integer %%BoundingBox. Applications
that support it prefer it; others ignore it.
2. 2dp rectangle geometry
Rectangle geometry (bars in ps_put_rect() and the background rectangle) is
output with 2 decimal places, i.e. quantised to 0.01pt (3.5um). This affects
X-dimensions that are not a multiple of 0.01pt, which includes the nominal
EAN/UPC X-dimension of 0.33mm (0.935433pt). The patch increases this to 4dp,
consistent with the HiResBoundingBox. Colour values and circles stay at 2dp.
As fm_putsf() strips trailing zeros, output for values that are whole or
already exact at 2dp is unchanged.
Example, zint -b EAN13 -d 501234567890 --scalexdimdp=0.33mm,72dpi -o out.eps:
before: %%BoundingBox: 0 0 106 56
51.45 3.74 I 10.29 0.94 R
after: %%BoundingBox: 0 0 106 56
%%HiResBoundingBox: 0 0 105.7039 55.1905
51.4488 3.7417 I 10.2898 0.9354 R
105.7039pt = 113 modules x 0.33mm = 37.29mm exactly.
Affected expected files in backend/tests/data/eps were regenerated with
test_ps -g; all test_ps tests pass (976 assertions). Output verified to
render and scan correctly (Ghostscript, zbar).
Thanks very much, patch added with commit [a1bfa8]. Also added your EAN13 0.33mm example to the the EPS test files, regards, Martin
Related
Commit: [a1bfa8]