svgtypes/lib.rs
1// Copyright 2018 the SVG Types Authors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4/*!
5*svgtypes* is a collection of parsers for [SVG](https://www.w3.org/TR/SVG2/) types.
6
7## Supported SVG types
8
9- [`<color>`](https://www.w3.org/TR/css-color-3/)
10- [`<number>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGNumber)
11- [`<length>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGLength)
12- [`<angle>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGAngle)
13- [`<viewBox>`](https://www.w3.org/TR/SVG2/coords.html#ViewBoxAttribute)
14- [`<path>`](https://www.w3.org/TR/SVG2/paths.html#PathData)
15- [`<transform>`](https://www.w3.org/TR/SVG11/types.html#DataTypeTransformList)
16- [`<list-of-numbers>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGNumberList)
17- [`<list-of-lengths>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGLengthList)
18- [`<list-of-points>`](https://www.w3.org/TR/SVG11/shapes.html#PointsBNF)
19- [`<filter-value-list>`](https://www.w3.org/TR/filter-effects-1/#typedef-filter-value-list)
20- [`<paint>`](https://www.w3.org/TR/SVG2/painting.html#SpecifyingPaint)
21- [`<preserveAspectRatio>`](https://www.w3.org/TR/SVG11/coords.html#PreserveAspectRatioAttribute)
22- [`<enable-background>`](https://www.w3.org/TR/SVG11/filters.html#EnableBackgroundProperty)
23- [`<IRI>`](https://www.w3.org/TR/SVG11/types.html#DataTypeIRI)
24- [`<FuncIRI>`](https://www.w3.org/TR/SVG11/types.html#DataTypeFuncIRI)
25- [`paint-order`](https://www.w3.org/TR/SVG2/painting.html#PaintOrder)
26
27## Features
28
29- Complete support of paths, so data like `M10-20A5.5.3-4 110-.1` will be parsed correctly.
30- Implicit path commands will be automatically converted into explicit one.
31- Some SVG2 data types support.
32- Pretty fast.
33
34## Limitations
35
36- Accepts only [normalized](https://www.w3.org/TR/REC-xml/#AVNormalize) values,
37 e.g. an input text should not contain ` ` or `&data;`.
38- All keywords must be lowercase.
39 Case-insensitive parsing is supported only for colors (requires allocation for named colors).
40- The `<color>` followed by the `<icccolor>` is not supported. As the `<icccolor>` itself.
41- [System colors](https://www.w3.org/TR/css3-color/#css2-system), like `fill="AppWorkspace"`,
42 are not supported. They were deprecated anyway.
43
44## Safety
45
46- The library should not panic. Any panic considered as a critical bug and should be reported.
47- The library forbids unsafe code.
48
49## Alternatives
50
51None.
52*/
53
54#![no_std]
55#![forbid(unsafe_code)]
56#![deny(missing_docs)]
57#![deny(missing_debug_implementations)]
58#![deny(missing_copy_implementations)]
59
60extern crate alloc;
61
62macro_rules! matches {
63 ($expression:expr, $($pattern:tt)+) => {
64 match $expression {
65 $($pattern)+ => true,
66 _ => false
67 }
68 }
69}
70
71mod angle;
72mod aspect_ratio;
73mod color;
74#[rustfmt::skip] mod colors;
75mod directional_position;
76mod enable_background;
77mod error;
78mod filter_functions;
79mod font;
80mod funciri;
81mod length;
82mod number;
83mod paint;
84mod paint_order;
85mod path;
86mod points;
87mod stream;
88mod transform;
89mod transform_origin;
90mod viewbox;
91
92use crate::stream::{ByteExt, Stream};
93
94pub use crate::angle::*;
95pub use crate::aspect_ratio::*;
96pub use crate::color::*;
97pub use crate::directional_position::*;
98pub use crate::enable_background::*;
99pub use crate::error::*;
100pub use crate::filter_functions::*;
101pub use crate::font::*;
102pub use crate::funciri::*;
103pub use crate::length::*;
104pub use crate::number::*;
105pub use crate::paint::*;
106pub use crate::paint_order::*;
107pub use crate::path::*;
108pub use crate::points::*;
109pub use crate::transform::*;
110pub use crate::transform_origin::*;
111pub use crate::viewbox::*;