SVG export: a small positive pixel size is not written as 0

In a pixel document, or with Units set to Pixels, the root `width` and
`height` were rounded to the chosen decimals, so a size below half the
last decimal place was written as 0 while the `viewBox` kept a positive
value. Both now keep enough digits to stay positive, and sizes that need
more than 14 decimal places are written in scientific notation, so two
tiny sides keep their proportions.
This commit is contained in:
dotCooCoo committed 2026-12-02 02:05:08 -08:00
1 parent 7554b7fc30
commit 90212adefd
5 files changed
+40 -12

No files matched your search

+1 -1
View File
@@ -474,7 +474,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi
- **Done (2026-11-03):** SVG Options › Units (`units`) explicitly overrides `width` and `height` with `px`
(bare numbers; CSS pixels are 96 per inch), `pt`, `mm`, `cm` or `in`, with the `viewBox` in points (#4462).
Responsive omits both dimensions; unknown units and explicit null are errors. Without an override, export
retains the document's physical units as below. Estimate unchanged.
retains the document's physical units as below; positive root `width`/`height` and `viewBox` dimensions that would round to 0 at the chosen decimals use enough digits to stay positive. Estimate unchanged.
- **Done (#864):** SVG export writes physical unit suffixes on the root `<svg width="..." height="...">` for documents with physical units (`mm`, `cm`, `in`, `pc`; documents in feet and yards are written in `in`, in meters in `cm`, and in Q or Ha in `mm`, since SVG has no unit for them: `every_physical_document_unit_exports_its_printed_size`), so external vector tools (Inkscape, LightBurn) and browsers render drawings at their intended physical scale rather than scaling to 75% under point-based user-unit assumptions; unitless user coordinates in `viewBox` and path geometry remain in 1:1 internal points per SVG 1.1 coords §7.10. A round trip keeps `mm`, `cm`, `in` and `pc` documents in their unit (`export_physical_units_writes_unit_suffixes`, `svg_round_trip_preserves_document_units`); documents in feet, yards, meters, Q or Ha keep their printed size and open again in the SVG unit they were written in. General document unit preferences across restarts remain tracked under #864.
- **Missing:** general document unit preference on restart (#864; SVG export physical units done). Shape Builder regions (#937, closed), PDF text placement
(#722, above), the bezier drag preview (#834, #3065, #3729) and deleting an interior anchor of an open path (above)
+1 -1
View File
@@ -1357,7 +1357,7 @@ SVG Options: `export` to SVG takes them in `options`, flat or as `{"svg": {…}}
SVG, or returned as `linked`), `objectIds` (`layerNames`, `minimal`, `unique`), `decimals` (1–7), `minify`,
`responsive`, `units` (`px`, `pt`, `mm`, `cm` or `in`: overrides the document unit for `width` and `height`; omit to retain the document unit, explicit null is rejected; `px` means bare numbers, the `viewBox` stays in points; ignored with `responsive`), `useArtboards`, `range: "all"` (one SVG per artboard, listed in `files`, each holding only the art over its artboard), `preserveEditing` (the SVG
reopens as the full document), `metadata` and `fewerTspans` (one `<tspan>` per line of type). Unknown keys inside `svg` are rejected; `run_command document.formats`
lists every option with its default. `encoding` is `utf8`, `utf16` (big-endian after a byte order mark) or `latin1`
lists every option with its default. If `decimals` would round a positive dimension to zero, root `width`/`height` values in unitless or px form and `viewBox` sizes use enough digits to stay positive, with scientific notation when more than 14 decimal places are needed. `encoding` is `utf8`, `utf16` (big-endian after a byte order mark) or `latin1`
(ISO 8859-1, other characters as `&#x…;` references); `document.serialize` still answers `text`, plus `dataBase64`
(the file) when it isn't UTF-8, and such files open again. `profile: "tiny12"` writes a simplified SVG Tiny 1.2
(presentation attributes only; filters, masks, blend modes and embedded fonts left out, symbols as art, each with