https://github.com/googlefonts/picosvg
Helps simplify SVG files. Intended for use as part of a font build.
https://github.com/googlefonts/picosvg
Last synced: over 1 year ago
JSON representation
Helps simplify SVG files. Intended for use as part of a font build.
- Host: GitHub
- URL: https://github.com/googlefonts/picosvg
- Owner: googlefonts
- License: apache-2.0
- Created: 2020-04-04T19:25:03.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-01-29T15:11:18.000Z (over 1 year ago)
- Last Synced: 2025-03-28T18:07:17.184Z (over 1 year ago)
- Language: Python
- Size: 883 KB
- Stars: 161
- Watchers: 21
- Forks: 12
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- Contributing: docs/contributing.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/googlefonts/picosvg/actions/workflows/ci.yml?query=workflow%3ATest)
[](https://pypi.org/project/picosvg/)
[](https://github.com/googlefonts/picosvg/network/updates)
# picosvg
Tool to simplify SVGs. Converts an input svg into a "pico" svg:
* Exactly 1 `` element, first child of root
* Only gradients defined under ``
* After the initial ``, only `` and ``
* `` is eliminated when possible, but may be retained for opacity
* Only absolute coordinates
* Only commands that specify full coordinates, no shorthand (H, S, etc)
Clip paths and strokes are rendered into equivalent paths using [Skia](https://skia.org/) via [skia-pathops](https://github.com/fonttools/skia-pathops), `` references are materialized, etc.
Some SVG features are not supported, of particular note:
* ``
* ``
Usage:
```shell
pip install -e .
picosvg mysvg.svg
```
Requires Python 3.8 or greater.
## Test
Install the dev dependencies specified in [`extras_require`](https://github.com/googlefonts/picosvg/blob/main/setup.py#L36-L40).
```shell
pip install -e .[dev]
pytest
```
If you use zsh, it will prompt an error(`zsh: no matches found: .[dev]`). Please use the following command:
```shell
pip install -e '.[dev]'
```
You can also use [pytest](https://docs.pytest.org/) to test the specified files individually.
```shell
pytest tests/svg_test.py
```
If you need to test a certain function (for example: test_topicosvg), please execute:
```shell
pytest tests/svg_test.py::test_topicosvg
```
If you need to display detailed diff information, please execute:
```shell
pytest tests/svg_test.py::test_topicosvg --vv
```
## Releasing
See https://googlefonts.github.io/python#make-a-release.