Native format: the preview and PDF of a save at a fixed precision show the rounded art

A save with `precision` rounded only the native document, and drew the
embedded preview and the `pdfCompatible` PDF from the exact document.
An app reading the PDF showed paths up to 0.5 pt away from what
VectorCraft reopens at `precision: 0`.

When `precision` is set, the preview and the PDF are now drawn from a
copy of the document rounded as the file holds it. For an older version,
placed documents in that copy become groups of their art first, as the
file stores them, so their rounded art shows too.

Tests: a save at precision 0 puts the path in the embedded PDF on the
rounded coordinates, and its preview matches the one drawn from the
saved document; the same for a version 3 save of a placed document.
This commit is contained in:
dotCooCoo
2026-10-25 08:35:53 -07:00
parent 60700e00fc
commit a4878b873e
4 changed files with 65 additions and 3 deletions
+1 -1
View File
@@ -599,7 +599,7 @@ their content). `version: 2` or `1` writes a file older VectorCraft versions ope
compressed), and `preview: true` embeds a PNG of the first artboard, at most 256 px on its longer side.
`precision: 4` (0 to 9) rounds the anchors and handles of paths to that many decimal places (in the layers, symbols,
graph designs, patterns, opacity masks and brushes); colors, transforms, opacity and type are written exactly.
Without `precision` a save writes the coordinates exactly, and Save does not remember it. A `.ai` file ignores
The embedded preview and the PDF that `pdfCompatible: true` adds show the rounded paths. Without `precision` a save writes the coordinates exactly, and Save does not remember it. A `.ai` file ignores
`precision`. A save writes
a temporary file and renames it over the old one, so a failed save never damages the file; only the images the
document uses are written, and document keys written by a newer version are kept.