Files
craft-libs/crates/svg/src/lib.rs
T
FredApps b836a71856 craft-svg: a paths feature, and CSS colours with their alpha (#1848)
The geometry reader (craft_svg::paths) is the only part of the crate that
needs vectorcraft-geom and vectorcraft-pathops, and the tree is the only part
that needs craft-image-codecs. Both are now optional: paths is a default
feature and tree turns it on, so existing users build the same crate, while
an app that only needs SVG text, guards, path data, colours and the writer can
turn default features off and take no app crates or image codecs.

parse_color_alpha is parse_color keeping the alpha of #rgba, #rrggbbaa and
the fourth value of rgb()/hsl(). parse_color now calls it and still drops it.

Refs #778, #789
2026-11-16 06:54:06 -05:00

33 lines
1.4 KiB
Rust

//! SVG: the one place the Craft apps' SVG format code lives.
//!
//! - [`sniff`]: is this an SVG, or a gzip-compressed one (SVGZ)?
//! - [`svgz`]: SVG text from the bytes of a file: SVGZ unpacked within a byte limit, UTF-8,
//! UTF-16 and ISO 8859-1 decoded; and SVGZ compression.
//! - [`guard`]: checks on the text before any XML reader or SVG converter sees it: how deep the
//! elements nest, and what the document type's entities expand to.
//! - `paths` (feature `paths`, on by default): the geometry of a document as Bézier paths in
//! millimetres, for cutters, plotters and CAD import.
//! - [`color`]: CSS colours.
//! - [`write`]: a writer for SVG documents, their path data and numbers.
//! - `tree` (feature `tree`): the full parser. usvg at the one version the Craft apps share,
//! re-exported, behind an entry point that runs the checks above before it parses.
//!
//! Input is treated as hostile throughout: every size, count and depth is bounded, and a file
//! past a bound is an error, never a panic or an unbounded allocation.
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
#![forbid(unsafe_code)]
pub mod color;
pub mod drawing_write;
pub mod guard;
pub mod neutral_document;
pub mod path_data;
#[cfg(feature = "paths")]
pub mod paths;
pub mod preflight;
pub mod sniff;
pub mod svgz;
#[cfg(feature = "tree")]
pub mod tree;
pub mod write;