fix(assets): export-icon crops to the artwork; build refuses a page-sized icon viewBox (#205) #221
No reviewers
Labels
No labels
build-dist
priority
P1
priority
P2
priority
P3
priority
P4
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Toilville/toilville-design!221
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/205-export-icon-artwork-bounds"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
For #205: ville's finding that
export-iconexports the whole document.Scope
Problem:
export-icon.jsexported the whole Affinity document. An icon drawn on A4 came out at 2481 × 3508, andassets.pypreserves the source viewBox, so the icon shipped tiny inside a large transparent area. Nothing caught it.Change:
export-icon.jsexports the artwork's bounds.FileExportArea.createForSelection(…)todoc.export, built withSelection.create(doc, doc.layers, true)from every layer, so the designer's own selection is untouched.JSLib/document.js(Document.export(path, options, exportArea, size),FileExportArea.createForSelection), read from the installed Affinity.app.udg/generators/svg_bounds.pycomputes an over-approximated artwork box: control points, arc radii and composed transforms. Content underdefs,clipPathandmaskis skipped.assets.pyfails an icon whose artwork spans less than 75% of its viewBox in either dimension, with a message saying how to fix it.Testing
generator/tests/unit/test_icon_viewbox.py:export-iconwrites its file once and passes the export area. The scripts run only inside Affinity, so this followstest_affinity_scripts.py's precedent of checking the source.MIN_ICON_COVERAGE = 0.0, the A4 test fails; with the area argument removed fromexport-icon, the static test fails. Both restored afterwards.python -m pytest generator/tests: 418 passed, 2 skipped.assets.py check --all: ok.export-icononce on a small shape in an A4 document and confirm the SVG's viewBox fits the shape.Impact Statement
iconcategory; no output changes for existing icons (check --allis clean).