Repository navigation
M4: SVG Options, area type and gradients in SVG export, ids and names, SVGZ (M4.26–M4.30) - #68
Merged
Merged
Conversation
document.export, serialize and save, and the Save As / Save a Copy UI
commands, take the SVG options flat or as svg: {…}: styling
(presentation, style, entities, css), outlineText, images (embed or
link; linked files are written next to the SVG), objectIds (layerNames,
minimal, unique), decimals 1–7, minify, responsive, useArtboards and
range "all" (one SVG per artboard), preserveEditing (the SVG reopens as
the full document) and metadata. Unknown keys are rejected and
document.formats lists every option with its default. Results carry the
SVG writer's warnings.
Save writes SVG to an .svg path and Save again reuses its options.
Export As SVG and Save As / Save a Copy to .svg open SVG Options (first
use: Internal CSS and Responsive, then the last-used choices) with a
read-only code view. Save a Copy no longer retargets the document.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every laid-out line of type is written at its own position (wraps, indents, tabs, hyphenation and all caps as on the canvas): a positioned tspan per style run and, on justified lines, per word. Centred and right-aligned lines are anchored at their centre or right end, so they stay aligned in a viewer whose font differs. Leading comes from the layout's baselines, baseline shift is written as dy, horizontal scale as textLength, vertical scale as the size, tracking and manual kerning as letter-spacing. The fewerTspans option (engine and dialog) writes one positioned tspan per line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Character gradients on live type export as url(#…) spanning the laid-out text (point, area, on-path and outlined type, as on the canvas); character stroke gradients span the text grown by half the weight. Identical gradients share one def, and a swatch gradient takes the swatch's name as its id. Midpoints are written as extra stops marked data-vc-midpoint, which import turns back into midpoints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Layer Names writes readable ids plus data-name with the original name whenever the id differs; Minimal writes only the ids definitions need; Unique prefixes every id and CSS class with a content hash, so SVGs inlined in one page never collide. Import names objects and layers from data-name, inkscape:label, serif:id or aria-label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
svgz is a writable format with the SVG options (document.export, serialize, save, Export for Screens): exactly the SVG export, gzipped. SVGZ is recognised by its extension or the gzip magic bytes and opens, places and pastes like SVG (clipboard.importSvg takes dataBase64 of SVG or SVGZ); Export As SVG or Save As to a .svgz name writes it compressed. Gzip lives in the svg crate (pure-Rust flate2, builds for wasm) and unpacking stops at 512 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of M4 (Files). SVG export gets Illustrator's SVG Options, line-accurate area type, faithful gradients, ids and names that survive the round trip, and SVGZ in and out. This ports an earlier session's work onto current
mainand reconciles it with #10 and the M3 SVG export work.document.export,serializeandsave, andfile.saveAs/file.saveCopy, take SVG options flat or assvg: {…}.range: "all", preserveEditing and metadata.document.formatslists each option with its default.svgOptions(file.export.svg, and Save As / Save a Copy to.svg) has a code view and remembers the last choices. It starts with Internal CSS and Responsive on.ExportOptionsgains Deserialize, anObjectIdsenum andImageMode. New fields:DocState.save_optionsandUiState.svg_options.Encodedcarries warnings).<tspan>per laid-out line and style run (per word on justified lines), plusfewerTspans.text-anchor.dy; spaces where a line wraps are dropped.url(#…)over the layout bounds.data-vc-midpointstops that come back on import (Gradient::expanded()).data-name; import readsdata-name,inkscape:label,serif:idandaria-label.svgzis a writable format and works through open, place, paste, save, export and Export for Screens.is_svgz,compress,text_of), and decompression stops at 512 MB.docs/mcp.mdanddocs/control-protocol.mdcover the options and the dialog. MCP's export format list gainssvgz.Checks
Rebased onto
2df7edd(#67).cargo xtask cipasses all 7 steps (fmt, clippy, test, assets, brands, layers, wasm): 2,015 tests, 0 failed.mainstill exists (1,981 → 2,012);UI_COMMANDS, menu entries and MCP tools are kept (two UI commands andsvgzadded).formats_query_lists_readers_writers_and_options,export_tool_lists_engine_formats_and_options,opens_every_readable_format.object_idsis now an enum:prop_svg::all_options,options_decimals_minify_responsive_artboard,full_document_roundtrip_is_stable.groups_and_names_roundtrip.styling_modes_roundtripis extended to cover entities.🤖 Generated with Claude Code