1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5/*!
6`usvg` (micro SVG) is an [SVG] parser that tries to solve most of SVG complexity.
7
8SVG is notoriously hard to parse. `usvg` presents a layer between an XML library and
9a potential SVG rendering library. It will parse an input SVG into a strongly-typed tree structure
10were all the elements, attributes, references and other SVG features are already resolved
11and presented in the simplest way possible.
12So a caller doesn't have to worry about most of the issues related to SVG parsing
13and can focus just on the rendering part.
14
15## Features
16
17- All supported attributes are resolved.
18 No need to worry about inheritable, implicit and default attributes
19- CSS will be applied
20- Only simple paths
21 - Basic shapes (like `rect` and `circle`) will be converted into paths
22 - Paths contain only absolute *MoveTo*, *LineTo*, *QuadTo*, *CurveTo* and *ClosePath* segments.
23 ArcTo, implicit and relative segments will be converted
24- `use` will be resolved and replaced with the reference content
25- Nested `svg` will be resolved
26- Invalid, malformed elements will be removed
27- Relative length units (mm, em, etc.) will be converted into pixels/points
28- External images will be loaded
29- Internal, base64 images will be decoded
30- All references (like `#elem` and `url(#elem)`) will be resolved
31- `switch` will be resolved
32- Text elements, which are probably the hardest part of SVG, will be completely resolved.
33 This includes all the attributes resolving, whitespaces preprocessing (`xml:space`),
34 text chunks and spans resolving
35- Markers will be converted into regular elements. No need to place them manually
36- All filters are supported. Including filter functions, like `filter="contrast(50%)"`
37- Recursive elements will be detected and removed
38- `objectBoundingBox` will be replaced with `userSpaceOnUse`
39
40## Limitations
41
42- Unsupported SVG features will be ignored
43- CSS support is minimal
44- Only [static](http://www.w3.org/TR/SVG11/feature#SVG-static) SVG features,
45 e.g. no `a`, `view`, `cursor`, `script`, no events and no animations
46
47[SVG]: https://en.wikipedia.org/wiki/Scalable_Vector_Graphics
48*/
49
50#![forbid(unsafe_code)]
51#![warn(missing_docs)]
52#![warn(missing_debug_implementations)]
53#![warn(missing_copy_implementations)]
54
55mod parser;
56mod tree;
57mod writer;
58
59pub use parser::*;
60pub use tree::*;
61
62pub use roxmltree;
63
64#[cfg(feature = "text")]
65mod text_to_paths;
66#[cfg(feature = "text")]
67pub use fontdb;
68
69pub use writer::WriteOptions;
70pub use xmlwriter::Indent;
71