• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H03-May-2022-14,48610,665

tests/H03-May-2022-133102

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D04-Jul-202074 65

Cargo.lockH A D04-Jul-20208.5 KiB339299

Cargo.tomlH A D04-Jul-20202 KiB10179

Cargo.toml.orig-cargoH A D04-Jul-20201.3 KiB5952

README.mdH A D02-Jul-20202.7 KiB7354

README.md

1# usvg
2[![Crates.io](https://img.shields.io/crates/v/usvg.svg)](https://crates.io/crates/usvg)
3[![Documentation](https://docs.rs/usvg/badge.svg)](https://docs.rs/usvg)
4
5*usvg* (micro SVG) is an [SVG] simplification tool.
6
7## Purpose
8
9Imagine, that you have to extract some data from the [SVG] file, but your
10library/framework/language doesn't have a good SVG library.
11And all you need is paths data.
12
13You can try to export it by yourself (how hard can it be, right).
14All you need is an XML library (I'll hope that your language has one).
15But soon you realize that paths data has a pretty complex format and a lot
16of edge-cases. And we didn't mention attributes propagation, transforms,
17visibility flags, attribute values validation, XML quirks, etc.
18It will take a lot of time and code to implement this stuff correctly.
19
20So, instead of creating a library that can be used from any language (impossible),
21*usvg* takes a different approach. It converts an input SVG into an extremely
22simple representation, which is still a valid SVG.
23And now, all you need is an XML library with some small amount of code.
24
25## Key features of the simplified SVG
26
27- No basic shapes (rect, circle, etc). Only paths
28- Simple paths:
29  - Only *MoveTo*, *LineTo*, *CurveTo* and *ClosePath* will be produced
30  - All path segments are in absolute coordinates
31  - No implicit segment commands
32  - All values are separated by a space
33- All (supported) attributes are resolved. No implicit one
34- `use` will be resolved
35- Invisible elements will be removed
36- Invalid elements (like `rect` with negative/zero size) will be removed
37- Units (mm, em, etc.) will be resolved
38- Comments will be removed
39- DTD will be resolved
40- CSS will be resolved
41- `style` attribute will be resolved
42- `inherit` attribute value will be resolved
43- `currentColor` attribute value will be resolved
44- Paint fallback will be resolved
45- No `script` (simply ignoring it)
46
47Full spec can be found [here](../docs/usvg_spec.adoc).
48
49## Limitations
50
51- Currently, its not lossless. Some SVG features isn't supported yet and will be ignored.
52- CSS support is minimal.
53- Only [static](http://www.w3.org/TR/SVG11/feature#SVG-static) SVG features,
54  e.g. no: `a`, `view`, `cursor`, `script` and [animations](https://www.w3.org/TR/SVG/animate.html).
55- Font-based elements are not supported.
56
57## Dependency
58
59The latest stable [Rust](https://www.rust-lang.org/).
60
61## FAQ
62
63### How to ensure that SVG is a valid "Micro" SVG?
64
65You can't. The idea is that you should not store files produced by *usvg*.
66You should use them immediately. Like an intermediate data.
67
68## License
69
70*usvg* is licensed under the [MPLv2.0](https://www.mozilla.org/en-US/MPL/).
71
72[SVG]: https://en.wikipedia.org/wiki/Scalable_Vector_Graphics
73