Files
craft-libs/crates/svg/Cargo.toml
Dylan M. Taylor 43f65a9210 craft-svg: usvg behind a bounded tree feature; attribute guard; Inkscape layer names (#937)
* craft-svg paths: a shape carries the name of its Inkscape layer

Shape::layer is the inkscape:label (else the id) of the innermost
<g inkscape:groupmode="layer"> around the element, so a CAD or cutter
import can keep the drawing's layers.

* craft-svg guard: bound attributes per element and over the document; find entities holding markup

too_wide is the attribute check of storytold/figcraft#2251: an XML
reader checks each attribute against the earlier ones on its element,
so an element with millions of them is quadratic work before any other
limit applies. entity_holds_markup lets a caller refuse a document type
whose entities become elements, as PhotoCraft does.

* craft-svg: feature `tree`, usvg behind one bounded entry point

usvg 0.48.1 (Apache-2.0 OR MIT), re-exported as craft_svg::tree::usvg,
so every app parses with one version and one set of checks:
tree::parse runs svgz, the entity, attribute and nesting guards, the
reference-chain height (VectorCraft's depth::height, on this crate's
cascade), then usvg. tree::image_resolver bounds embedded SVGs
(FigCraft's budget::resolver). tree::draw bounds what drawing a tree
with resvg allocates (PhotoCraft's svg/limits.rs).

Part of #778 and #789.
2026-11-11 18:46:38 -05:00

31 lines
1.1 KiB
TOML

[package]
name = "craft-svg"
description = "SVG: sniffing, SVGZ and text encodings, pre-parse limits, a geometry reader (Bézier paths in millimetres), CSS colours and a writer"
version.workspace = true
edition.workspace = true
license.workspace = true
rust-version.workspace = true
repository.workspace = true
[lints]
workspace = true
[dependencies]
craft-xml = { workspace = true }
# SVGZ (gzip), pure-Rust backend.
flate2 = { version = "1", default-features = false, features = ["rust_backend"] }
kurbo = { workspace = true }
roxmltree = "0.21.2"
thiserror = { workspace = true }
# The full SVG parser (Apache-2.0 OR MIT). The one version every Craft app uses: apps depend on
# craft-svg's `tree` feature and take usvg from its re-export, never directly.
usvg = { version = "=0.48.1", default-features = false, optional = true }
[features]
# `craft_svg::tree`: usvg behind the bounded entry point.
tree = ["dep:usvg"]
# Text converted to paths (needs a font database in the options).
tree-text = ["tree", "usvg/text"]
# The system's fonts in `usvg::fontdb`.
tree-system-fonts = ["tree-text", "usvg/system-fonts"]