Compare commits
305 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a124f9f415 | |||
|
|
0609c59676 | ||
|
|
85f4b49d59 | ||
|
|
897e3f565c | ||
|
|
fbf0c06e84 | ||
|
|
841ad54e7f | ||
|
|
68c1e545da | ||
|
|
a7a16799a2 | ||
|
|
7b9c4ee935 | ||
|
|
aa9796ea87 | ||
|
|
7a83e7148d | ||
|
|
04bf3d79a0 | ||
|
|
b8a071f995 | ||
|
|
92e64f0d7f | ||
|
|
23835da44a | ||
|
|
f56843acc0 | ||
|
|
c84731e12d | ||
|
|
ab97a01427 | ||
|
|
f0788d5c0d | ||
|
|
9a1286132f | ||
|
|
cc11ef3d5e | ||
|
|
ca2b32c0b3 | ||
|
|
3d29029c72 | ||
|
|
0e82b8dcad | ||
|
|
a3f761f40c | ||
|
|
36ee0932a4 | ||
|
|
9e3a5f2e40 | ||
|
|
ace24df5c3 | ||
|
|
985cb58a26 | ||
|
|
1bb875192f | ||
|
|
fd2daf44b4 | ||
|
|
045f1f0ad5 | ||
|
|
29a7474f74 | ||
|
|
528ad91418 | ||
|
|
c5362743c3 | ||
|
|
5881890e44 | ||
|
|
4e489b7ea9 | ||
|
|
397ffc5529 | ||
|
|
9656569a72 | ||
|
|
5be6b03d7c | ||
|
|
21f1262bcb | ||
|
|
47e8b15315 | ||
|
|
a15acb3e4e | ||
|
|
dd2155e576 | ||
|
|
40753af88a | ||
|
|
f65ca60809 | ||
|
|
4fe2655f86 | ||
|
|
58b75c314a | ||
|
|
6846e0c9ee | ||
|
|
f61b4d36d6 | ||
|
|
09a656287d | ||
|
|
695676e3a5 | ||
|
|
049264eba6 | ||
|
|
5ccba31ff9 | ||
|
|
718748ff22 | ||
|
|
651694a6c0 | ||
|
|
703122369e | ||
|
|
2200f8dc81 | ||
|
|
e1c2699f07 | ||
|
|
7d28f5e051 | ||
|
|
06ea23d0e1 | ||
|
|
8c95d950af | ||
|
|
5d579f8927 | ||
|
|
3c64623a12 | ||
|
|
9f4a707bb7 | ||
|
|
8a2892b458 | ||
|
|
c504891bd7 | ||
|
|
47f918e696 | ||
|
|
18e57cddae | ||
|
|
a459d629c1 | ||
|
|
039022ee9d | ||
|
|
e25b0dae73 | ||
|
|
91503c6d7e | ||
|
|
d6406a3470 | ||
|
|
8ddb7d8913 | ||
|
|
0ec0732447 | ||
|
|
20dcbcbe64 | ||
|
|
1650f91ea4 | ||
|
|
5dc1b7a820 | ||
|
|
00cf42b554 | ||
|
|
0254014e06 | ||
|
|
3283d6d5ec | ||
|
|
103dcc0a48 | ||
|
|
ba7f4b5f18 | ||
|
|
f8d5af0e56 | ||
|
|
d508f59aa6 | ||
|
|
b622642aa1 | ||
|
|
38274f75bc | ||
|
|
a2c94c96fb | ||
|
|
6ea126d290 | ||
|
|
cae0faefa0 | ||
|
|
7115e82cb8 | ||
|
|
0776d32179 | ||
|
|
5360db86d9 | ||
|
|
2f0b3ea362 | ||
|
|
cb093e9171 | ||
|
|
c54a7239e7 | ||
|
|
b916a189e9 | ||
|
|
633b381d87 | ||
|
|
7249ae8b0a | ||
|
|
843706be39 | ||
|
|
f3d8936b5e | ||
|
|
b20a0698cc | ||
|
|
0a146b7fef | ||
|
|
7e14cd352f | ||
|
|
f14784b01f | ||
|
|
fef2786c5e | ||
|
|
695a91e447 | ||
|
|
7ee5f9774d | ||
|
|
e36cd4832a | ||
|
|
49f3664f82 | ||
|
|
53d87ed35a | ||
|
|
c089448bb5 | ||
|
|
e0bfad272b | ||
|
|
992b6850c6 | ||
|
|
cc592c8e8a | ||
|
|
75bacbc8e6 | ||
|
|
62b16c11d8 | ||
|
|
5bfffc2ca8 | ||
|
|
98e3040645 | ||
|
|
51c1e6af23 | ||
|
|
c2a65a772e | ||
|
|
12237e01c8 | ||
|
|
090884a70f | ||
|
|
2ebe9741b2 | ||
|
|
a7e7b4c21d | ||
|
|
7cb0d36d72 | ||
|
|
ffeb76c894 | ||
|
|
f7d6406d38 | ||
|
|
0f6d9be4e2 | ||
|
|
3b41d3a547 | ||
|
|
0ffefcd8bb | ||
|
|
01cb120d71 | ||
|
|
3e4c8d793f | ||
|
|
f5a61eeeb3 | ||
|
|
7c2e035644 | ||
|
|
a69efb3a55 | ||
|
|
8f87118725 | ||
|
|
b00b374e64 | ||
|
|
210c5f64ab | ||
|
|
25549b35d3 | ||
|
|
6cf8c2b7d9 | ||
|
|
c45f050fe6 | ||
|
|
d9b369864d | ||
|
|
49cb542689 | ||
|
|
285d73e5a6 | ||
|
|
2fe7152a1e | ||
|
|
91ee9d2112 | ||
|
|
de1441fd58 | ||
|
|
902e112a96 | ||
|
|
8cc97601c4 | ||
|
|
462460a512 | ||
|
|
8d20805976 | ||
|
|
7e2b5e43df | ||
|
|
284beae36c | ||
|
|
45a2869a17 | ||
|
|
829b630d64 | ||
|
|
47cfb9aa0e | ||
|
|
24c8087bd4 | ||
|
|
2487f4433b | ||
|
|
4410f91dad | ||
|
|
4a5b924d37 | ||
|
|
8ac344daf2 | ||
|
|
18970e0ba1 | ||
|
|
e1e3051de0 | ||
|
|
582c2dd9b7 | ||
|
|
42dc70874c | ||
|
|
79390dc0e4 | ||
|
|
fb9ffb3dbd | ||
|
|
f27ad1e416 | ||
|
|
d9198d7872 | ||
|
|
99363c9089 | ||
|
|
82df0d2327 | ||
|
|
fc356815a2 | ||
|
|
0f1974c1e2 | ||
|
|
943319b710 | ||
|
|
9b80fc55a2 | ||
|
|
9629e87f37 | ||
|
|
082b579410 | ||
|
|
b065137187 | ||
|
|
cd8b723fed | ||
|
|
10e687b887 | ||
|
|
0b5bb5184c | ||
|
|
0b5eab7f2f | ||
|
|
1cde426009 | ||
|
|
600ec2868c | ||
|
|
1aa5722c6a | ||
|
|
0fac95ee09 | ||
|
|
ec855211de | ||
|
|
564367f886 | ||
|
|
25c05d99d8 | ||
|
|
dc3f66ed0f | ||
|
|
0c63344ea4 | ||
|
|
21e6c7491b | ||
|
|
29e005bf7b | ||
|
|
9e4b9d6f5e | ||
|
|
3929426a5a | ||
|
|
e76da093ea | ||
|
|
bf4fc1b70e | ||
|
|
e57adf0c96 | ||
|
|
fa17e6655a | ||
|
|
3b68fdacf8 | ||
|
|
aa48c90d56 | ||
|
|
842123a393 | ||
|
|
3511c05298 | ||
|
|
beea442fce | ||
|
|
0314070363 | ||
|
|
5844076258 | ||
|
|
419f41cb48 | ||
|
|
c433077e6f | ||
|
|
fbf4e13e8d | ||
|
|
0cbf89641a | ||
|
|
7c86de83d1 | ||
|
|
488c756989 | ||
|
|
002c54b5cc | ||
|
|
cbda5dcd86 | ||
|
|
beb9823a91 | ||
|
|
90910eaa6f | ||
|
|
386d5d8656 | ||
|
|
8d6301950b | ||
|
|
4f23ea7a34 | ||
|
|
57f93efc89 | ||
|
|
fe2884c3e8 | ||
|
|
3299f8f6e0 | ||
|
|
df142a2f22 | ||
|
|
3f5c6c76c0 | ||
|
|
06457a7461 | ||
|
|
e41893d98f | ||
|
|
a766a3256b | ||
|
|
c564b89d21 | ||
|
|
371f14786a | ||
|
|
8a2d9d604d | ||
|
|
f83b03707b | ||
|
|
84b36c7109 | ||
|
|
1a8ece216d | ||
|
|
d2faa6bffd | ||
|
|
6bb2b35ba2 | ||
|
|
6a23a4cd71 | ||
|
|
d710fb3f6c | ||
|
|
99dc0dfae9 | ||
|
|
b14e801cb7 | ||
|
|
70e6fb776e | ||
|
|
ea610e5c09 | ||
|
|
0d6725e05d | ||
|
|
77906518c0 | ||
|
|
72c2ec8e1c | ||
|
|
ab90d18cb2 | ||
|
|
7c3331d6f6 | ||
|
|
b042c93b2c | ||
|
|
cf08a72e41 | ||
|
|
e701acdc25 | ||
|
|
1a9d6119e0 | ||
|
|
170f8c7baa | ||
|
|
939dd160bc | ||
|
|
73ec7da13e | ||
|
|
07e9ec0257 | ||
|
|
f05d73b859 | ||
|
|
dccb80314c | ||
|
|
184efee16e | ||
|
|
fbf4e3ec2e | ||
|
|
972812e6c7 | ||
|
|
232f27269a | ||
|
|
130a71327a | ||
|
|
0a0a062718 | ||
|
|
c698522c28 | ||
|
|
946ca3ce4a | ||
|
|
8984e550b0 | ||
|
|
4eade69201 | ||
|
|
1a6ff29c14 | ||
|
|
32e7e5517f | ||
|
|
ab1aa0e2f8 | ||
|
|
f0c69b827e | ||
|
|
2293e1bd4a | ||
|
|
c54c5e5d7e | ||
|
|
320bdda6e9 | ||
|
|
391ff77659 | ||
|
|
3b7e8a0091 | ||
|
|
ebccae8cad | ||
|
|
6254548582 | ||
|
|
46a2ada361 | ||
|
|
532f664001 | ||
|
|
89f4b687f2 | ||
|
|
67bacc2f23 | ||
|
|
b979fe19e5 | ||
|
|
302f7f7477 | ||
|
|
d3b29a68da | ||
|
|
ec7385c995 | ||
|
|
e903475289 | ||
|
|
27d5cd3881 | ||
|
|
7e36be4aaa | ||
|
|
e21e362353 | ||
|
|
18266ca1ec | ||
|
|
a5b09e3824 | ||
|
|
03f099a26e | ||
|
|
d1c66cc75b | ||
|
|
85dff51cc9 | ||
|
|
26a360a00c | ||
|
|
43ee078ee6 | ||
|
|
e01fac82a4 | ||
|
|
e7332f6704 | ||
|
|
f7165f66a9 | ||
|
|
9bb929d91e | ||
|
|
edcaeba905 | ||
|
|
c27ca4db8a | ||
|
|
ae4d9303f1 |
30
.travis.yml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
sudo: false
|
||||
|
||||
language: python
|
||||
|
||||
python:
|
||||
- pypy
|
||||
- 2.7
|
||||
- 3.4
|
||||
- 3.5
|
||||
- 3.6
|
||||
- 3.7
|
||||
- 3.8
|
||||
- 3.9
|
||||
- 3.10-dev
|
||||
install:
|
||||
- pip install tox-travis codecov
|
||||
|
||||
script:
|
||||
- tox
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
include:
|
||||
- python: 3.9
|
||||
env:
|
||||
- TOXENV=flake8
|
||||
|
||||
after_success:
|
||||
- coverage combine && codecov
|
||||
35
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# Contributing
|
||||
|
||||
Contributions to Scour are welcome, feel free to create a pull request!
|
||||
|
||||
In order to be able to merge your PR as fast as possible please try to stick to the following guidelines.
|
||||
|
||||
> _**TL;DR** (if you now what you're doing) – Always run [`make check`](https://github.com/scour-project/scour/blob/master/Makefile) before creating a PR to check for common problems._
|
||||
|
||||
|
||||
## Code Style
|
||||
|
||||
The Scour project tries to follow the coding conventions described in [PEP 8 - The Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/). While there are some inconsistencies in existing code (e.g. with respect to naming conventions and the usage of globals), new code should always abide by the standard.
|
||||
|
||||
To quickly check for common mistakes you can use [`flake8`](https://pypi.python.org/pypi/flake8). Our [Makefile](https://github.com/scour-project/scour/blob/master/Makefile) has a convenience target with the correct options:
|
||||
```Makefile
|
||||
make flake8
|
||||
```
|
||||
|
||||
## Unit Tests
|
||||
|
||||
In order to check functionality of Scour and prevent any regressions in existing code a number of tests exist which use the [`unittest`](https://docs.python.org/library/unittest.html) unit testing framework which ships with Python. You can quickly run the tests by using the [Makefile](https://github.com/scour-project/scour/blob/master/Makefile) convenience target:
|
||||
```Makefile
|
||||
make test
|
||||
```
|
||||
|
||||
These tests are run automatically on all PRs using [TravisCI](https://travis-ci.org/scour-project/scour) and have to pass at all times! When you add new functionality you should always include suitable tests with your PR (see [`test_scour.py`](https://github.com/scour-project/scour/blob/master/test_scour.py)).
|
||||
|
||||
### Coverage
|
||||
|
||||
To ensure that all possible code conditions are covered by a test you can use [`coverage`](https://pypi.python.org/pypi/coverage). The [Makefile](https://github.com/scour-project/scour/blob/master/Makefile) convenience target automatically creates an HTML report in `htmlcov/index.html`:
|
||||
```Makefile
|
||||
make coverage
|
||||
```
|
||||
|
||||
These reports are also created automatically by our TravisCI builds and are accessible via [Codecov](https://codecov.io/gh/scour-project/scour)
|
||||
347
HISTORY.md
Normal file
|
|
@ -0,0 +1,347 @@
|
|||
# Release Notes for Scour
|
||||
|
||||
## Version 0.38.2 (2020-11-22)
|
||||
* Fix another regression caused by new feature to merge sibling groups ([#260](https://github.com/scour-project/scour/issues/260))
|
||||
|
||||
## Version 0.38.1 (2020-09-02)
|
||||
* Fix regression caused by new feature to merge sibling groups ([#260](https://github.com/scour-project/scour/issues/260))
|
||||
|
||||
## Version 0.38 (2020-08-06)
|
||||
* Fix issue with dropping xlink:href attribute when collapsing referenced gradients ([#206](https://github.com/scour-project/scour/pull/206))
|
||||
* Fix issue with dropping ID while de-duplicating gradients ([#207](https://github.com/scour-project/scour/pull/207))
|
||||
* Improve `--shorten-ids` so it re-maps IDs that are already used in the document if they're shorter ([#187](https://github.com/scour-project/scour/pull/187))
|
||||
* Fix whitespace handling for SVG 1.2 flowed text ([#235](https://github.com/scour-project/scour/issues/235))
|
||||
* Improvement: Merge sibling `<g>` nodes with identical attributes ([#208](https://github.com/scour-project/scour/pull/208))
|
||||
* Improve performance of XML serialization ([#247](https://github.com/scour-project/scour/pull/247))
|
||||
* Improve performance of gradient de-duplication ([#248](https://github.com/scour-project/scour/pull/248))
|
||||
* Some general performance improvements ([#249](https://github.com/scour-project/scour/pull/249))
|
||||
|
||||
## Version 0.37 (2018-07-04)
|
||||
* Fix escaping of quotes in attribute values. ([#152](https://github.com/scour-project/scour/pull/152))
|
||||
* A lot of performance improvements making processing significantly faster in many cases. ([#167](https://github.com/scour-project/scour/pull/167), [#169](https://github.com/scour-project/scour/pull/169), [#171](https://github.com/scour-project/scour/pull/171), [#185](https://github.com/scour-project/scour/pull/185))
|
||||
* Fix exception when removing duplicated gradients while `--keep-unreferenced-defs` is used ([#173](https://github.com/scour-project/scour/pull/173))
|
||||
* Remove some illegal optimizations of `m0 0` sub-path commands ([#178](https://github.com/scour-project/scour/pull/178))
|
||||
* Fix and improve handling of boolean flags in elliptical arc path commands ([#183](https://github.com/scour-project/scour/pull/183))
|
||||
* Fix exception when shorthand transform `scale(1)` with single number is used ([#191](https://github.com/scour-project/scour/pull/191))
|
||||
* Fix exception when using two-number forms of the filter attributes `baseFrequency`, `order`, `radius` and `stdDeviation` ([#192](https://github.com/scour-project/scour/pull/192))
|
||||
* Improve whitespace handling in text nodes fixing an issue where scouring added spaces in error and reducing file size in many cases ([#199](https://github.com/scour-project/scour/pull/199))
|
||||
* Drop official support for Python 3.3. (While it will probably continue to work for a while compatibility is not guaranteed anymore. If you continue to use Scour with Python 3.3 and should find/fix any compatibility issues pull requests are welcome, though.)
|
||||
|
||||
|
||||
## Version 0.36 (2017-08-06)
|
||||
* Fix embedding of raster images which was broken in most cases and did not work at all in Python 3. ([#120](https://github.com/scour-project/scour/issues/120))
|
||||
* Some minor fixes for statistics output.
|
||||
* Greatly improve the algorithm to reduce numeric precision.
|
||||
* Precision was not properly reduced for some numbers.
|
||||
* Only use reduced precision if it results in a shorter string representation, otherwise preserve full precision in output (e.g. use "123" instead of "1e2" when precision is set to 1).
|
||||
* Reduce precision of lengths in `viewBox` ([#127](https://github.com/scour-project/scour/issues/127))
|
||||
* Add option `--set-c-precision` which allows to set a reduced numeric precision for control points.<br/>Control points determine how a path is bent in between two nodes and are less sensitive to a reduced precision than the position coordinates of the nodes themselves. This option can be used to save a few additional bytes without affecting visual appearance negatively.
|
||||
* Fix: Unnecessary whitespace was not stripped from elliptical paths. ([#89](https://github.com/scour-project/scour/issues/89))
|
||||
* Improve and fix functionality to collapse straight paths segments. ([#146](https://github.com/scour-project/scour/issues/146))
|
||||
* Collapse subpaths of moveto `m` and lineto `l`commands if they have the same direction (before we only collapsed horizontal/vertical `h`/`v` lineto commands).
|
||||
* Attempt to collapse lineto `l` commands into a preceding moveto `m` command (these are then called "implicit lineto commands")
|
||||
* Do not collapse straight path segments in paths that have intermediate markers. ([#145](https://github.com/scour-project/scour/issues/145))
|
||||
* Preserve empty path segments if they have `stroke-linecap` set to `round` or `square`. They render no visible line but a tiny dot or square.
|
||||
|
||||
|
||||
## Version 0.35 (2016-09-14)
|
||||
|
||||
* Drop official support for Python 2.6. (While it will probably continue to work for a while compatibility is not guaranteed anymore. If you continue to use Scour with Python 2.6 and should find/fix any compatibility issues pull requests are welcome, though.)
|
||||
* Fix: Unused IDs were not shortened when `--shorten-ids` was used. ([#19](https://github.com/scour-project/scour/issues/62))
|
||||
* Fix: Most elements were still removed from `<defs>` when `--keep-unreferenced-defs` was used. ([#62](https://github.com/scour-project/scour/issues/62))
|
||||
* Improve escaping of single/double quotes ('/") in attributes. ([#64](https://github.com/scour-project/scour/issues/64))
|
||||
* Print usage information if no input file was specified (and no data is available from `stdin`). ([#65](https://github.com/scour-project/scour/issues/65))
|
||||
* Redirect informational output to `stderr` when SVG is output to `stdout`. ([#67](https://github.com/scour-project/scour/issues/67))
|
||||
* Allow elements to be found via `Document.getElementById()` in the minidom document returned by scourXmlFile(). ([#68](https://github.com/scour-project/scour/issues/68))
|
||||
* Improve code to remove default attribute values and add a lot of new default values. ([#70](https://github.com/scour-project/scour/issues/70))
|
||||
* Fix: Only attempt to group elements that the content model allows to be children of a `<g>` when `--create-groups` is specified. ([#98](https://github.com/scour-project/scour/issues/98))
|
||||
* Fix: Update list of SVG presentation attributes allowing more styles to be converted to attributes and remove two entries (`line-height` and `visibility`) that were actually invalid. ([#99](https://github.com/scour-project/scour/issues/99))
|
||||
* Add three options that work analogous to `--remove-metadata` (removes `<metadata>` elements) ([#102](https://github.com/scour-project/scour/issues/102))
|
||||
* `--remove-titles` (removes `<title>` elements)
|
||||
* `--remove-descriptions` (removes `<desc>` elements)
|
||||
* `--remove-descriptive-elements` (removes all of the descriptive elements, i.e. `<title>`, `<desc>` and `<metadata>`)
|
||||
* Fix removal rules for the `overflow` attribute. ([#104](https://github.com/scour-project/scour/issues/104))
|
||||
* Improvement: Automatically order all attributes ([#105](https://github.com/scour-project/scour/issues/105)), as well as `style` declarations ([#107](https://github.com/scour-project/scour/issues/107)) allowing for a constant output across multiple runs of Scour. Before order could change arbitrarily.
|
||||
* Improve path scouring. ([#108](https://github.com/scour-project/scour/issues/108))<br>Notably Scour performs all calculations with enhanced precision now, guaranteeing maximum accuracy when optimizing path data. Numerical precision is reduced as a last step of the optimization according to the `--precision` option.
|
||||
* Fix replacement of removed duplicate gradients if the `fill`/`stroke` properties contained a fallback. ([#109](https://github.com/scour-project/scour/issues/109))
|
||||
* Fix conversion of cubic Bézier "curveto" commands into "shorthand/smooth curveto" commands. ([#110](https://github.com/scour-project/scour/issues/110))
|
||||
* Fix some issues due to removal of properties without considering inheritance rules. ([#111](https://github.com/scour-project/scour/issues/111))
|
||||
|
||||
|
||||
## Version 0.34 (2016-07-25)
|
||||
|
||||
* Add a function to sanitize an arbitrary Python object containing options for Scour as attributes (usage: `Scour.sanitizeOptions(options)`).<br>This simplifies usage of the Scour module by other scripts while avoiding any compatibility issues that might arise when options are added/removed/renamed in Scour. ([#44](https://github.com/scour-project/scour/issues/44))
|
||||
* Input/output file can now be specified as positional arguments (e.g. `scour input.svg output.svg`). ([#46](https://github.com/scour-project/scour/issues/46))
|
||||
* Improve `--help` output by intuitively arranging options in groups. ([#46](https://github.com/scour-project/scour/issues/46))
|
||||
* Add option `--error-on-flowtext` to raise an exception whenever a non-standard `<flowText>` element is found (which is only supported in Inkscape). If this option is not specified a warning will be shown. ([#53](https://github.com/scour-project/scour/issues/53))
|
||||
* Automate tests with continuous integration via Travis. ([#52](https://github.com/scour-project/scour/issues/52))
|
||||
|
||||
|
||||
## Version 0.33 (2016-01-29)
|
||||
|
||||
* Add support for removal of editor data of Sketch. ([#37](https://github.com/scour-project/scour/issues/37))
|
||||
* Add option `--verbose` (or `-v`) to show detailed statistics after running Scour. By default only a single line containing the most important information is output now.
|
||||
|
||||
|
||||
## Version 0.32 (2015-12-10)
|
||||
|
||||
* Add functionality to remove unused XML namespace declarations from the `<svg>` root element. ([#14](https://github.com/scour-project/scour/issues/14))
|
||||
* Restore unittests which were lost during move to GitHub. ([#24](https://github.com/scour-project/scour/issues/24))
|
||||
* Fix a potential regex matching issue in `points` attribute of `<polygon>` and `<polyline>` elements. ([#24](https://github.com/scour-project/scour/issues/24))
|
||||
* Fix a crash with `points` attribute of `<polygon>` and `<polyline>` starting with a negative number. ([#24](https://github.com/scour-project/scour/issues/24))
|
||||
* Fix encoding issues when input file contained unicode characters. ([#27](https://github.com/scour-project/scour/issues/27))
|
||||
* Fix encoding issues when using `stding`/`stdout` as input/output. ([#27](https://github.com/scour-project/scour/issues/27))
|
||||
* Fix removal of comments. If a node contained multiple comments usually not all of them were removed. ([#28](https://github.com/scour-project/scour/issues/28))
|
||||
|
||||
|
||||
## Version 0.31 (2015-11-16)
|
||||
|
||||
* Ensure Python 3 compatibility. ([#8](https://github.com/scour-project/scour/issues/8))
|
||||
* Add option `--nindent` to set the number of spaces/tabs used for indentation (defaults to 1). ([#13](https://github.com/scour-project/scour/issues/13))
|
||||
* Add option `--no-line-breaks` to suppress output of line breaks and indentation altogether. ([#13](https://github.com/scour-project/scour/issues/13))
|
||||
* Add option `--strip-xml-space` which removes the specification of `xml:space="preserve"` on the `<svg>` root element which would otherwise disallow Scour to make any whitespace changes in output. ([#13](https://github.com/scour-project/scour/issues/13))
|
||||
|
||||
|
||||
## Version 0.30 (2014-08-05)
|
||||
|
||||
* Fix ignoring of additional args when invoked from scons.
|
||||
|
||||
|
||||
## Version 0.29 (2014-07-26)
|
||||
|
||||
* Add option `--keep-unreferenced-defs` to preserve elements in `<defs>` that are not referenced and would be removed otherwise. ([#2](https://github.com/scour-project/scour/issues/2))
|
||||
* Add option to ignore unknown cmd line opts.
|
||||
|
||||
|
||||
## Version 0.28 (2014-01-12)
|
||||
|
||||
* Add option `--shorten-ids-prefix` which allows to add a custom prefix to all shortened IDs. ([#1](https://github.com/scour-project/scour/issues/1))
|
||||
|
||||
|
||||
## Version 0.27 (2013-10-26)
|
||||
|
||||
* Allow direct calling of the Scour module.
|
||||
|
||||
|
||||
## Version 0.26 (2013-10-22)
|
||||
|
||||
* Re-release of Scour 0.26, re-packaged as a Python module [available from PyPI](https://pypi.python.org/pypi/scour) (Thanks to [Tobias Oberstet](https://github.com/oberstet)!).
|
||||
* Development moved to GitHub (https://github.com/scour-project/scour).
|
||||
|
||||
|
||||
## Version 0.26 (2011-05-09)
|
||||
|
||||
* Fix [Bug 702423](https://bugs.launchpad.net/scour/+bug/702423) to function well in the presence of multiple identical gradients and `--disable-style-to-xml`.
|
||||
* Fix [Bug 722544](https://bugs.launchpad.net/scour/+bug/722544) to properly optimize transformation matrices. Also optimize more things away in transformation specifications. (Thanks to Johan Sundström for the patch.)
|
||||
* Fix [Bug 616150](https://bugs.launchpad.net/scour/+bug/616150) to run faster using the `--create-groups` option.
|
||||
* Fix [Bug 708515](https://bugs.launchpad.net/scour/+bug/562784) to handle raster embedding better in the presence of file:// URLs.
|
||||
* Fix [Bug 714717](https://bugs.launchpad.net/scour/+bug/714717) to avoid deleting renderable CurveTo commands in paths, which happen to end where they started.
|
||||
* Per [Bug 714727](https://bugs.launchpad.net/scour/+bug/714727) and [Bug 714720](https://bugs.launchpad.net/scour/+bug/714720), Scour now deletes text attributes, including "text-align", from elements and groups of elements that only contain shapes. (Thanks to Jan Thor for the patches.)
|
||||
* Per [Bug 714731](https://bugs.launchpad.net/scour/+bug/714731), remove the default value of more SVG attributes. (Thanks to Jan Thor for the patch.)
|
||||
* Fix [Bug 717826](https://bugs.launchpad.net/scour/+bug/717826) to emit the correct line terminator (CR LF) in optimized SVG content on the version of Scour used in Inkscape on Windows.
|
||||
* Fix [Bug 734933](https://bugs.launchpad.net/scour/+bug/734933) to avoid deleting renderable LineTo commands in paths, which happen to end where they started, if their stroke-linecap property has the value "round".
|
||||
* Fix [Bug 717254](https://bugs.launchpad.net/scour/+bug/717254) to delete `<defs>` elements that become empty after unreferenced element removal. (Thanks to Jan Thor for the patch.)
|
||||
* Fix [Bug 627372](https://bugs.launchpad.net/scour/+bug/627372) to future-proof the parameter passing between Scour and Inkscape. (Thanks to Bernd Feige for the patch.)
|
||||
* Fix [Bug 638764](https://bugs.launchpad.net/scour/+bug/638764), which crashed Scour due to [Python Issue 2531](http://bugs.python.org/issue2531) regarding floating-point handling in ArcTo path commands. (Thanks to [Walther](https://launchpad.net/~walther-md) for investigating this bug.)
|
||||
* Per [Bug 654759](https://bugs.launchpad.net/scour/+bug/654759), enable librsvg workarounds by default in Scour.
|
||||
* Added ID change and removal protection options per [bug 492277](https://bugs.launchpad.net/scour/+bug/492277): `--protect-ids-noninkscape`, `--protect-ids-prefix`, `--protect-ids-list`. (Thanks to Jan Thor for this patch.)
|
||||
|
||||
|
||||
## Version 0.25 (2010-07-11)
|
||||
|
||||
* Fix [Bug 541889](https://bugs.launchpad.net/scour/+bug/541889) to parse polygon/polyline points missing whitespace/comma separating a negative value. Always output points attributes as comma-separated.
|
||||
* Fix [Bug 519698](https://bugs.launchpad.net/scour/+bug/519698) to properly parse move commands that have line segments.
|
||||
* Fix [Bug 577940](https://bugs.launchpad.net/scour/+bug/577940) to include stroke-dasharray into list of style properties turned into XML attributes.
|
||||
* Fix [Bug 562784](https://bugs.launchpad.net/scour/+bug/562784), typo in Inkscape description
|
||||
* Fix [Bug 603988](https://bugs.launchpad.net/scour/+bug/603988), do not commonize attributes if the element is referenced elsewhere.
|
||||
* Fix [Bug 604000](https://bugs.launchpad.net/scour/+bug/604000), correctly remove default overflow attributes.
|
||||
* Fix [Bug 603994](https://bugs.launchpad.net/scour/+bug/603994), fix parsing of `<style>` element contents when a CDATA is present
|
||||
* Fix [Bug 583758](https://bugs.launchpad.net/scour/+bug/583758), added a bit to the Inkscape help text saying that groups aren't collapsed if IDs are also not stripped.
|
||||
* Fix [Bug 583458](https://bugs.launchpad.net/scour/+bug/583458), another typo in the Inkscape help tab.
|
||||
* Fix [Bug 594930](https://bugs.launchpad.net/scour/+bug/594930), In a `<switch>`, require one level of `<g>` if there was a `<g>` in the file already. Otherwise, only the first subelement of the `<g>` is chosen and rendered.
|
||||
* Fix [Bug 576958](https://bugs.launchpad.net/scour/+bug/576958), "Viewbox option doesn't work when units are set", when renderer workarounds are disabled.
|
||||
* Added many options: `--remove-metadata`, `--quiet`, `--enable-comment-stripping`, `--shorten-ids`, `--renderer-workaround`.
|
||||
|
||||
|
||||
## Version 0.24 (2010-02-05)
|
||||
|
||||
* Fix [Bug 517064](https://bugs.launchpad.net/scour/+bug/517064) to make XML well-formed again
|
||||
* Fix [Bug 503750](https://bugs.launchpad.net/scour/+bug/503750) fix Inkscape extension to correctly pass `--enable-viewboxing`
|
||||
* Fix [Bug 511186](https://bugs.launchpad.net/scour/+bug/511186) to allow comments outside of the root `<svg>` node
|
||||
|
||||
|
||||
## Version 0.23 (2010-01-04)
|
||||
|
||||
* Fix [Bug 482215](https://bugs.launchpad.net/scour/+bug/482215) by using os.linesep to end lines
|
||||
* Fix unittests to run properly in Windows
|
||||
* Removed default scaling of image to 100%/100% and creating a viewBox. Added `--enable-viewboxing` option to explicitly turn that on
|
||||
* Fix [Bug 503034](https://bugs.launchpad.net/scour/+bug/503034) by only removing children of a group if the group itself has not been referenced anywhere else in the file
|
||||
|
||||
|
||||
## Version 0.22 (2009-11-09)
|
||||
|
||||
* Fix [Bug 449803](https://bugs.launchpad.net/scour/+bug/449803) by ensuring input and output filenames differ.
|
||||
* Fix [Bug 453737](https://bugs.launchpad.net/scour/+bug/453737) by updated Inkscape's scour extension with a UI
|
||||
* Fix whitespace collapsing on non-textual elements that had xml:space="preserve"
|
||||
* Fix [Bug 479669](https://bugs.launchpad.net/scour/+bug/479669) to handle empty `<style>` elements.
|
||||
|
||||
|
||||
## Version 0.21 (2009-09-27)
|
||||
|
||||
* Fix [Bug 427309](https://bugs.launchpad.net/scour/+bug/427309) by updated Scour inkscape extension file to include yocto_css.py
|
||||
* Fix [Bug 435689](https://bugs.launchpad.net/scour/+bug/435689) by properly preserving whitespace in XML serialization
|
||||
* Fix [Bug 436569](https://bugs.launchpad.net/scour/+bug/436569) by getting `xlink:href` prefix correct with invalid SVG
|
||||
|
||||
|
||||
## Version 0.20 (2009-08-31)
|
||||
|
||||
* Fix [Bug 368716](https://bugs.launchpad.net/scour/+bug/368716) by implementing a really tiny CSS parser to find out if any style element have rules referencing gradients, filters, etc
|
||||
* Remove unused attributes from parent elements
|
||||
* Fix a bug with polygon/polyline point parsing if there was whitespace at the end
|
||||
|
||||
|
||||
## Version 0.19 (2009-08-13)
|
||||
|
||||
* Fix XML serialization bug: `xmlns:XXX` prefixes not preserved when not in default namespace
|
||||
* Fix XML serialization bug: remapping to default namespace was not actually removing the old prefix
|
||||
* Move common attributes to ancestor elements
|
||||
* Fix [Bug 412754](https://bugs.launchpad.net/scour/+bug/401628): Elliptical arc commands must have comma/whitespace separating the coordinates
|
||||
* Scour lengths for svg x,y,width,height,*opacity,stroke-width,stroke-miterlimit
|
||||
|
||||
|
||||
## Version 0.18 (2009-08-09)
|
||||
|
||||
* Remove attributes of gradients if they contain default values
|
||||
* Reduce bezier/quadratic (c/q) segments to their shorthand equivalents (s/t)
|
||||
* Move to a custom XML serialization such that `id`/`xml:id` is printed first (Thanks to Richard Hutch for the suggestion)
|
||||
* Added `--indent` option to specify indentation type (default='space', other options: 'none', 'tab')
|
||||
|
||||
|
||||
## Version 0.17 (2009-08-03)
|
||||
|
||||
* Only convert to #RRGGBB format if the color name will actually be shorter
|
||||
* Remove duplicate gradients
|
||||
* Remove empty q,a path segments
|
||||
* Scour polyline coordinates just like path/polygon
|
||||
* Scour lengths from most attributes
|
||||
* Remove redundant SVG namespace declarations and prefixes
|
||||
|
||||
|
||||
## Version 0.16 (2009-07-30)
|
||||
|
||||
* Fix [Bug 401628](https://bugs.launchpad.net/scour/+bug/401628): Keep namespace declarations when using `--keep-editor-data` (Thanks YoNoSoyTu!)
|
||||
* Remove trailing zeros after decimal places for all path coordinates
|
||||
* Use scientific notation in path coordinates if that representation is shorter
|
||||
* Scour polygon coordinates just like path coordinates
|
||||
* Add XML prolog to scour output to ensure valid XML, added `--strip-xml-prolog` option
|
||||
|
||||
|
||||
## Version 0.15 (2009-07-05)
|
||||
|
||||
* added `--keep-editor-data` command-line option
|
||||
* Fix [Bug 395645](https://bugs.launchpad.net/scour/+bug/395645): Keep all identified children inside a defs (Thanks Frederik!)
|
||||
* Fix [Bug 395647](https://bugs.launchpad.net/scour/+bug/395647): Do not remove closepath (Z) path segments
|
||||
|
||||
|
||||
## Version 0.14 (2009-06-10)
|
||||
|
||||
* Collapse adjacent commands of the same type
|
||||
* Convert straight curves into line commands
|
||||
* Eliminate last segment in a polygon
|
||||
* Rework command-line argument parsing
|
||||
* Fix bug in embedRasters() caused by new command-line parsing
|
||||
* added `--disable-embed-rasters` command-line option
|
||||
|
||||
|
||||
## Version 0.13 (2009-05-19)
|
||||
|
||||
* properly deal with `fill="url("#foo")"`
|
||||
* properly handle paths with more than 1 pair of coordinates in the first Move command
|
||||
* remove font/text styles from shape elements (font-weight, font-size, line-height, etc)
|
||||
* remove -inkscape-font-specification styles
|
||||
* added `--set-precision` argument to set the number of significant digits (defaults to 5 now)
|
||||
* collapse consecutive h,v coords/segments that go in the same direction
|
||||
|
||||
|
||||
## Version 0.12 (2009-05-17)
|
||||
|
||||
* upgraded enthought's path parser to handle scientific notation in path coordinates
|
||||
* convert colors to #RRGGBB format
|
||||
* added option to disable color conversion
|
||||
|
||||
|
||||
## Version 0.11 (2009-04-28)
|
||||
|
||||
* convert gradient stop offsets from percentages to float
|
||||
* convert gradient stop offsets to integers if possible (0 or 1)
|
||||
* fix bug in line-to-hv conversion
|
||||
* handle non-ASCII characters (Unicode)
|
||||
* remove empty line or curve segments from path
|
||||
* added option to prevent style-to-xml conversion
|
||||
* handle compressed svg (svgz) on the input and output
|
||||
* added total time taken to the report
|
||||
* Removed XML pretty printing because of [this problem](http://ronrothman.com/public/leftbraned/xml-dom-minidom-toprettyxml-and-silly-whitespace/).
|
||||
|
||||
|
||||
## Version 0.10 (2009-04-27)
|
||||
|
||||
* Remove path with empty d attributes
|
||||
* Sanitize path data (remove unnecessary whitespace)
|
||||
* Convert from absolute to relative path data
|
||||
* Remove trailing zeroes from path data
|
||||
* Limit to no more than 6 digits of precision
|
||||
* Remove empty line segments
|
||||
* Convert lines to horiz/vertical line segments where possible
|
||||
* Remove some more default styles (`display:none`, `visibility:visible`, `overflow:visible`,
|
||||
`marker:none`)
|
||||
|
||||
|
||||
## Version 0.09 (2009-04-25)
|
||||
|
||||
* Fix bug when removing stroke styles
|
||||
* Remove gradients that are only referenced by one other gradient
|
||||
* Added option to prevent group collapsing
|
||||
* Prevent groups with title/desc children from being collapsed
|
||||
* Remove stroke="none"
|
||||
|
||||
|
||||
## Version 0.08 (2009-04-22)
|
||||
|
||||
* Remove unnecessary nested `<g>` elements
|
||||
* Remove duplicate gradient stops (same offset, stop-color, stop-opacity)
|
||||
* Always keep fonts inside `<defs>`, always keep ids on fonts
|
||||
* made ID stripping optional (disabled by default)
|
||||
|
||||
|
||||
## Version 0.07 (2009-04-15)
|
||||
|
||||
* moved all functionality into a module level function named 'scour' and began adding unit tests
|
||||
* prevent metadata from being removed if they contain only text nodes
|
||||
* Remove unreferenced pattern and gradient elements outside of defs
|
||||
* Removal of extra whitespace, pretty printing of XML
|
||||
|
||||
|
||||
## Version 0.06 (2009-04-13)
|
||||
|
||||
* Prevent error when stroke-width property value has a unit
|
||||
* Convert width/height into a viewBox where possible
|
||||
* Convert all referenced rasters into base64 encoded URLs if the files can be found
|
||||
|
||||
|
||||
## Version 0.05 (2009-04-07)
|
||||
|
||||
* Removes unreferenced elements in a `<defs>`
|
||||
* Removes all inkscape, sodipodi, adobe elements
|
||||
* Removes all inkscape, sodipodi, adobe attributes
|
||||
* Remove all unused namespace declarations on the document element
|
||||
* Removes any empty `<defs>`, `<metadata>`, or `<g>` elements
|
||||
* Style fix-ups:
|
||||
* Fixes any style properties like this: `style="fill: url(#linearGradient1000) rgb(0, 0, 0);"`
|
||||
* Removes any style property of: `opacity: 1;`
|
||||
* Removes any stroke properties when `stroke=none` or `stroke-opacity=0` or `stroke-width=0`
|
||||
* Removes any fill properties when `fill=none` or `fill-opacity=0`
|
||||
* Removes all fill/stroke properties when `opacity=0`
|
||||
* Removes any `stop-opacity: 1`
|
||||
* Removes any `fill-opacity: 1`
|
||||
* Removes any `stroke-opacity: 1`
|
||||
* Convert style properties into SVG attributes
|
||||
34
Makefile
|
|
@ -1,15 +1,39 @@
|
|||
all: clean install
|
||||
|
||||
install:
|
||||
python setup.py install
|
||||
python3 setup.py install
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
rm -rf dist
|
||||
rm -rf scour.egg-info
|
||||
rm -rf .tox
|
||||
rm -f .coverage*
|
||||
rm -rf htmlcov
|
||||
find . -name "*.pyc" -type f -exec rm -f {} \;
|
||||
find . -name "*__pycache__" -type d -prune -exec rm -rf {} \;
|
||||
|
||||
publish: clean
|
||||
python setup.py register
|
||||
python setup.py sdist upload
|
||||
python setup.py bdist_egg upload
|
||||
python setup.py bdist_wininst upload
|
||||
python3 setup.py register
|
||||
python3 setup.py sdist upload
|
||||
|
||||
check: test flake8
|
||||
|
||||
|
||||
|
||||
test:
|
||||
python3 test_scour.py
|
||||
|
||||
test_version:
|
||||
PYTHONPATH=. python3 -m scour.scour --version
|
||||
|
||||
test_help:
|
||||
PYTHONPATH=. python3 -m scour.scour --help
|
||||
|
||||
flake8:
|
||||
flake8 --max-line-length=119
|
||||
|
||||
coverage:
|
||||
coverage run --source=scour test_scour.py
|
||||
coverage html
|
||||
coverage report
|
||||
|
|
|
|||
76
README.md
|
|
@ -1,52 +1,72 @@
|
|||
# Scour
|
||||
|
||||
Scour is a Python module that takes an input SVG and outputs a cleaner,
|
||||
more concise SVG file. The goal is that authors will use this script after
|
||||
editing the file in a GUI editor such as Inkscape or Adobe Illustrator.
|
||||
[](https://pypi.python.org/pypi/scour "Package listing on PyPI")
|
||||
|
||||
[](https://travis-ci.org/scour-project/scour "Build status (via TravisCI)")
|
||||
[](https://codecov.io/gh/scour-project/scour "Code coverage (via Codecov)")
|
||||
|
||||
Scour was started as a vehicle for me to learn Python. In addition, the goal
|
||||
is to reduce the amount of time I spend in cleaning up files I find on sites
|
||||
such as openclipart.org
|
||||
---
|
||||
|
||||
Ideas are pulled from three places:
|
||||
Scour is an SVG optimizer/cleaner written in Python that reduces the size of scalable vector graphics by optimizing structure and removing unnecessary data.
|
||||
|
||||
* my head
|
||||
* Sam Ruby's SVG Tidy script: http://intertwingly.net/code/svgtidy/svgtidy.rb
|
||||
* Inkscape's proposal for a 'cleaned SVG': http://wiki.inkscape.org/wiki/index.php/Save_Cleaned_SVG
|
||||
It can be used to create streamlined vector graphics suitable for web deployment, publishing/sharing or further processing.
|
||||
|
||||
Regards,
|
||||
The goal of Scour is to output a file that renders identically at a fraction of the size by removing a lot of redundant information created by most SVG editors. Optimization options are typically lossless but can be tweaked for more aggressive cleaning.
|
||||
|
||||
Jeff Schiller, 2009-04-06
|
||||
Scour is open-source and licensed under [Apache License 2.0](https://github.com/codedread/scour/blob/master/LICENSE).
|
||||
|
||||
codedread@gmail.com
|
||||
Scour was originally developed by Jeff "codedread" Schiller and Louis Simard in in 2010.
|
||||
The project moved to GitLab in 2013 an is now maintained by Tobias "oberstet" Oberstein and Patrick "Ede_123" Storz.
|
||||
|
||||
http://blog.codedread.com/
|
||||
This fork was created by Alexander Olsson ([alex@aleon.se](mailto:alex@aleon.se?subject=Scour)) at Aleon Apps.
|
||||
|
||||
http://www.codedread.com/scour/
|
||||
## Installation
|
||||
|
||||
Scour requires [Python](https://www.python.org) 2.7 or 3.4+. Further, for installation, [pip](https://pip.pypa.io) should be used.
|
||||
|
||||
To install this fork:
|
||||
|
||||
```console
|
||||
sudo make
|
||||
```
|
||||
|
||||
## Extension
|
||||
Place the modified extension files in the Inkscape extension directory
|
||||
```console
|
||||
sudo cp extension/* /usr/share/inkscape/extensions/
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Standard:
|
||||
|
||||
scour -i mysvg.svg -o mysvg_opt.svg
|
||||
```console
|
||||
scour -i input.svg -o output.svg
|
||||
```
|
||||
|
||||
Better (this works in IE which needs Viewbox):
|
||||
Better (for older versions of Internet Explorer):
|
||||
|
||||
scour -i mysvg.svg -o mysvg_opt.svg --enable-viewboxing
|
||||
```console
|
||||
scour -i input.svg -o output.svg --enable-viewboxing
|
||||
```
|
||||
|
||||
Maximum:
|
||||
Maximum scrubbing:
|
||||
|
||||
scour -i mysvg.svg -o mysvg_opt.svg --enable-viewboxing --enable-id-stripping \
|
||||
--enable-comment-stripping --shorten-ids --indent=none
|
||||
```console
|
||||
scour -i input.svg -o output.svg --enable-viewboxing --enable-id-stripping \
|
||||
--enable-comment-stripping --shorten-ids --indent=none
|
||||
```
|
||||
|
||||
Maximum + Compress:
|
||||
Maximum scrubbing and a compressed SVGZ file:
|
||||
|
||||
scour -i mysvg.svg -o mysvg_opt.svgz --enable-viewboxing --enable-id-stripping \
|
||||
--enable-comment-stripping --shorten-ids --indent=none
|
||||
```console
|
||||
scour -i input.svg -o output.svgz --enable-viewboxing --enable-id-stripping \
|
||||
--enable-comment-stripping --shorten-ids --indent=none
|
||||
```
|
||||
|
||||
## Notes
|
||||
Remove scientific notation from path data:
|
||||
|
||||
Packaging from [sources](http://www.codedread.com/scour/) retrieved on 2013/20/22:
|
||||
```console
|
||||
scour -i input.svg -o output.svgz --nonsci-output
|
||||
```
|
||||
|
||||
* done by Tavendo GmbH, Tobias Oberstein
|
||||
* license same as upstream (Apache 2.0)
|
||||
|
|
|
|||
132
extension/output_scour.inx
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>Optimized SVG Output</name>
|
||||
<id>org.inkscape.output.scour_inkscape</id>
|
||||
|
||||
<param name="tab" type="notebook">
|
||||
<page name="Options" gui-text="Options">
|
||||
<param gui-text="Number of significant digits for coordinates:"
|
||||
gui-description="Specifies the number of significant digits that should be output for coordinates. Note that significant digits are *not* the number of decimals but the overall number of digits in the output. For example if a value of "3" is specified, the coordinate 3.14159 is output as 3.14 while the coordinate 123.675 is output as 124."
|
||||
name="set-precision" type="int" min="1">5</param>
|
||||
<spacer/>
|
||||
<param gui-text="Shorten color values"
|
||||
gui-description="Convert all color specifications to #RRGGBB (or #RGB where applicable) format."
|
||||
name="simplify-colors" type="bool">true</param>
|
||||
<param gui-text="Convert CSS attributes to XML attributes"
|
||||
gui-description="Convert styles from style tags and inline style="" declarations into XML attributes."
|
||||
name="style-to-xml" type="bool">true</param>
|
||||
<spacer/>
|
||||
<param gui-text="Collapse groups"
|
||||
gui-description="Remove useless groups, promoting their contents up one level. Requires "Remove unused IDs" to be set."
|
||||
name="group-collapsing" type="bool">true</param>
|
||||
<param gui-text="Create groups for similar attributes"
|
||||
gui-description="Create groups for runs of elements having at least one attribute in common (e.g. fill-color, stroke-opacity, ...)."
|
||||
name="create-groups" type="bool">true</param>
|
||||
<spacer/>
|
||||
<param gui-text="Keep editor data"
|
||||
gui-description="Don't remove editor-specific elements and attributes. Currently supported: Inkscape, Sodipodi and Adobe Illustrator."
|
||||
name="keep-editor-data" type="bool">false</param>
|
||||
<param gui-text="Remove scientific notation"
|
||||
gui-description="Remove scientific notation from path data."
|
||||
name="nonsci-output" type="bool">false</param>
|
||||
<param gui-text="Keep unreferenced definitions"
|
||||
gui-description="Keep element definitions that are not currently used in the SVG"
|
||||
name="keep-unreferenced-defs" type="bool">false</param>
|
||||
<spacer/>
|
||||
<param gui-text="Work around renderer bugs"
|
||||
gui-description="Works around some common renderer bugs (mainly libRSVG) at the cost of a slightly larger SVG file."
|
||||
name="renderer-workaround" type="bool">true</param>
|
||||
</page>
|
||||
<page name="Output" gui-text="SVG Output">
|
||||
<label appearance="header">Document options</label>
|
||||
<param gui-text="Remove the XML declaration"
|
||||
gui-description="Removes the XML declaration (which is optional but should be provided, especially if special characters are used in the document) from the file header."
|
||||
name="strip-xml-prolog" type="bool">false</param>
|
||||
<param gui-text="Remove metadata"
|
||||
gui-description="Remove metadata tags along with all the contained information, which may include license and author information, alternate versions for non-SVG-enabled browsers, etc."
|
||||
name="remove-metadata" type="bool">false</param>
|
||||
<param gui-text="Remove comments"
|
||||
gui-description="Remove all XML comments from output."
|
||||
name="enable-comment-stripping" type="bool">false</param>
|
||||
<param gui-text="Embed raster images"
|
||||
gui-description="Resolve external references to raster images and embed them as Base64-encoded data URLs."
|
||||
name="embed-rasters" type="bool">true</param>
|
||||
<param gui-text="Enable viewboxing"
|
||||
gui-description="Set page size to 100%/100% (full width and height of the display area) and introduce a viewBox specifying the drawings dimensions."
|
||||
name="enable-viewboxing" type="bool">false</param>
|
||||
<spacer/>
|
||||
<label appearance="header">Pretty-printing</label>
|
||||
<param gui-text="Format output with line-breaks and indentation"
|
||||
gui-description="Produce nicely formatted output including line-breaks. If you do not intend to hand-edit the SVG file you can disable this option to bring down the file size even more at the cost of clarity."
|
||||
name="line-breaks" type="bool">true</param>
|
||||
<param gui-text="Indentation characters:"
|
||||
gui-description="The type of indentation used for each level of nesting in the output. Specify "None" to disable indentation. This option has no effect if "Format output with line-breaks and indentation" is disabled."
|
||||
name="indent" type="optiongroup" appearance="combo">
|
||||
<option value="space">Space</option>
|
||||
<option value="tab">Tab</option>
|
||||
<option context="Indent" value="none">None</option>
|
||||
</param>
|
||||
<param gui-text="Depth of indentation:"
|
||||
gui-description="The depth of the chosen type of indentation. E.g. if you choose "2" every nesting level in the output will be indented by two additional spaces/tabs."
|
||||
name="nindent" type="int">1</param>
|
||||
<param gui-text="Strip the "xml:space" attribute from the root SVG element"
|
||||
gui-description="This is useful if the input file specifies "xml:space='preserve'" in the root SVG element which instructs the SVG editor not to change whitespace in the document at all (and therefore overrides the options above)."
|
||||
name="strip-xml-space" type="bool">false</param>
|
||||
</page>
|
||||
<page name="IDs" gui-text="IDs">
|
||||
<param gui-text="Remove unused IDs"
|
||||
gui-description="Remove all unreferenced IDs from elements. Those are not needed for rendering."
|
||||
name="enable-id-stripping" type="bool">true</param>
|
||||
<spacer/>
|
||||
<param gui-text="Shorten IDs"
|
||||
gui-description="Minimize the length of IDs using only lowercase letters, assigning the shortest values to the most-referenced elements. For instance, "linearGradient5621" will become "a" if it is the most used element."
|
||||
name="shorten-ids" type="bool">false</param>
|
||||
<param gui-text="Prefix shortened IDs with:"
|
||||
gui-description="Prepend shortened IDs with the specified prefix."
|
||||
name="shorten-ids-prefix" type="string"></param>
|
||||
<spacer/>
|
||||
<param gui-text="Preserve manually created IDs not ending with digits"
|
||||
gui-description="Descriptive IDs which were manually created to reference or label specific elements or groups (e.g. #arrowStart, #arrowEnd or #textLabels) will be preserved while numbered IDs (as they are generated by most SVG editors including Inkscape) will be removed/shortened."
|
||||
name="protect-ids-noninkscape" type="bool">true</param>
|
||||
<param gui-text="Preserve the following IDs:"
|
||||
gui-description="A comma-separated list of IDs that are to be preserved."
|
||||
name="protect-ids-list" type="string"></param>
|
||||
<param gui-text="Preserve IDs starting with:"
|
||||
gui-description="Preserve all IDs that start with the specified prefix (e.g. specify "flag" to preserve "flag-mx", "flag-pt", etc.)."
|
||||
name="protect-ids-prefix" type="string"></param>
|
||||
</page>
|
||||
<page name="About" gui-text="About">
|
||||
<hbox>
|
||||
<image>output_scour.svg</image>
|
||||
<spacer/>
|
||||
<vbox>
|
||||
<spacer/>
|
||||
<label>Optimized SVG Output is provided by</label>
|
||||
<label appearance="header" indent="1">Scour - An SVG Scrubber</label>
|
||||
<spacer/>
|
||||
<label>For details please refer to</label>
|
||||
<label appearance="url" indent="1">https://github.com/scour-project/scour</label>
|
||||
</vbox>
|
||||
</hbox>
|
||||
<spacer size="expand"/>
|
||||
<hbox>
|
||||
<label>This version of the extension is designed for</label>
|
||||
<label>Scour 0.31+</label>
|
||||
</hbox>
|
||||
<param name="scour-version" type="string" gui-hidden="true">0.31</param> <!-- this parameter is checked programmatically in the extension to show a warning -->
|
||||
<param gui-text="Show warnings for older versions of Scour"
|
||||
name="scour-version-warn-old" type="bool">true</param>
|
||||
</page>
|
||||
</param>
|
||||
|
||||
<output>
|
||||
<extension>.svg</extension>
|
||||
<mimetype>image/svg+xml</mimetype>
|
||||
<filetypename>Optimized SVG (*.svg)</filetypename>
|
||||
<filetypetooltip>Scalable Vector Graphics</filetypetooltip>
|
||||
</output>
|
||||
|
||||
<script>
|
||||
<command location="inx" interpreter="python">output_scour.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
||||
100
extension/output_scour.py
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Run the scour module on the svg output.
|
||||
"""
|
||||
|
||||
|
||||
import inkex
|
||||
from inkex.localization import inkex_gettext as _
|
||||
|
||||
try:
|
||||
from packaging.version import Version
|
||||
except ImportError:
|
||||
raise inkex.DependencyError(
|
||||
_(
|
||||
"""Failed to import module 'packaging'.
|
||||
Please make sure it is installed (e.g. using 'pip install packaging'
|
||||
or 'sudo apt-get install python3-packaging') and try again.
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
try:
|
||||
import scour
|
||||
from scour.scour import scourString
|
||||
except ImportError:
|
||||
raise inkex.DependencyError(
|
||||
_(
|
||||
"""Failed to import module 'scour'.
|
||||
Please make sure it is installed (e.g. using 'pip install scour'
|
||||
or 'sudo apt-get install python3-scour') and try again.
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class ScourInkscape(inkex.OutputExtension):
|
||||
"""Scour Inkscape Extension"""
|
||||
|
||||
# Scour options
|
||||
def add_arguments(self, pars):
|
||||
pars.add_argument("--tab")
|
||||
pars.add_argument("--simplify-colors", type=inkex.Boolean, dest="simple_colors")
|
||||
pars.add_argument("--style-to-xml", type=inkex.Boolean)
|
||||
pars.add_argument(
|
||||
"--group-collapsing", type=inkex.Boolean, dest="group_collapse"
|
||||
)
|
||||
pars.add_argument("--create-groups", type=inkex.Boolean, dest="group_create")
|
||||
pars.add_argument("--enable-id-stripping", type=inkex.Boolean, dest="strip_ids")
|
||||
pars.add_argument("--shorten-ids", type=inkex.Boolean)
|
||||
pars.add_argument("--shorten-ids-prefix")
|
||||
pars.add_argument("--embed-rasters", type=inkex.Boolean)
|
||||
pars.add_argument(
|
||||
"--keep-unreferenced-defs", type=inkex.Boolean, dest="keep_defs"
|
||||
)
|
||||
pars.add_argument("--keep-editor-data", type=inkex.Boolean)
|
||||
pars.add_argument("--nonsci-output", type=inkex.Boolean)
|
||||
pars.add_argument("--remove-metadata", type=inkex.Boolean)
|
||||
pars.add_argument("--strip-xml-prolog", type=inkex.Boolean)
|
||||
pars.add_argument("--set-precision", type=int, dest="digits")
|
||||
pars.add_argument("--indent", dest="indent_type")
|
||||
pars.add_argument("--nindent", type=int, dest="indent_depth")
|
||||
pars.add_argument("--line-breaks", type=inkex.Boolean, dest="newlines")
|
||||
pars.add_argument(
|
||||
"--strip-xml-space", type=inkex.Boolean, dest="strip_xml_space_attribute"
|
||||
)
|
||||
pars.add_argument("--protect-ids-noninkscape", type=inkex.Boolean)
|
||||
pars.add_argument("--protect-ids-list")
|
||||
pars.add_argument("--protect-ids-prefix")
|
||||
pars.add_argument("--enable-viewboxing", type=inkex.Boolean)
|
||||
pars.add_argument(
|
||||
"--enable-comment-stripping", type=inkex.Boolean, dest="strip_comments"
|
||||
)
|
||||
pars.add_argument("--renderer-workaround", type=inkex.Boolean)
|
||||
|
||||
# options for internal use of the extension
|
||||
pars.add_argument("--scour-version")
|
||||
pars.add_argument("--scour-version-warn-old", type=inkex.Boolean)
|
||||
|
||||
def save(self, stream):
|
||||
# version check if enabled in options
|
||||
if self.options.scour_version_warn_old:
|
||||
scour_version = scour.__version__
|
||||
scour_version_min = self.options.scour_version
|
||||
if Version(scour_version) < Version(scour_version_min):
|
||||
raise inkex.AbortExtension(
|
||||
f"""
|
||||
The extension 'Optimized SVG Output' is designed for Scour {scour_version_min} or later but you're
|
||||
using the older version Scour {scour_version}.
|
||||
|
||||
Note: You can permanently disable this message on the 'About' tab of the extension window."""
|
||||
)
|
||||
del self.options.scour_version
|
||||
del self.options.scour_version_warn_old
|
||||
|
||||
# do the scouring
|
||||
stream.write(scourString(self.svg.tostring(), self.options).encode("utf8"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ScourInkscape().run()
|
||||
5
extension/output_scour.svg
Normal file
|
After Width: | Height: | Size: 33 KiB |
|
|
@ -1,22 +1,19 @@
|
|||
###############################################################################
|
||||
##
|
||||
## Copyright (C) 2013 Tavendo GmbH
|
||||
##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License");
|
||||
## you may not use this file except in compliance with the License.
|
||||
## You may obtain a copy of the License at
|
||||
##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0
|
||||
##
|
||||
## Unless required by applicable law or agreed to in writing, software
|
||||
## distributed under the License is distributed on an "AS IS" BASIS,
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
## See the License for the specific language governing permissions and
|
||||
## limitations under the License.
|
||||
##
|
||||
#
|
||||
# Copyright (C) 2010 Jeff Schiller, 2010 Louis Simard, 2013-2015 Tavendo GmbH
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
import scour
|
||||
import svg_regex
|
||||
import svg_transform
|
||||
import yocto_css
|
||||
__version__ = u'0.38.2'
|
||||
|
|
|
|||
6491
scour/scour.py
28
scour/stats.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
class ScourStats(object):
|
||||
|
||||
__slots__ = (
|
||||
'num_elements_removed',
|
||||
'num_attributes_removed',
|
||||
'num_style_properties_fixed',
|
||||
'num_bytes_saved_in_colors',
|
||||
'num_ids_removed',
|
||||
'num_comments_removed',
|
||||
'num_style_properties_fixed',
|
||||
'num_rasters_embedded',
|
||||
'num_path_segments_removed',
|
||||
'num_points_removed_from_polygon',
|
||||
'num_bytes_saved_in_path_data',
|
||||
'num_bytes_saved_in_colors',
|
||||
'num_bytes_saved_in_comments',
|
||||
'num_bytes_saved_in_ids',
|
||||
'num_bytes_saved_in_lengths',
|
||||
'num_bytes_saved_in_transforms',
|
||||
)
|
||||
|
||||
def __init__(self):
|
||||
self.reset()
|
||||
|
||||
def reset(self):
|
||||
# Set all stats to 0
|
||||
for attr in self.__slots__:
|
||||
setattr(self, attr, 0)
|
||||
|
|
@ -41,15 +41,22 @@ Out[4]: [('M', [(0.60509999999999997, 0.5)])]
|
|||
In [5]: svg_parser.parse('M 100-200') # Another edge case
|
||||
Out[5]: [('M', [(100.0, -200.0)])]
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import re
|
||||
from decimal import *
|
||||
from decimal import Decimal, getcontext
|
||||
from functools import partial
|
||||
|
||||
|
||||
# Sentinel.
|
||||
|
||||
|
||||
class _EOF(object):
|
||||
|
||||
def __repr__(self):
|
||||
return 'EOF'
|
||||
|
||||
|
||||
EOF = _EOF()
|
||||
|
||||
lexicon = [
|
||||
|
|
@ -69,6 +76,7 @@ class Lexer(object):
|
|||
|
||||
http://www.gooli.org/blog/a-simple-lexer-in-python/
|
||||
"""
|
||||
|
||||
def __init__(self, lexicon):
|
||||
self.lexicon = lexicon
|
||||
parts = []
|
||||
|
|
@ -91,6 +99,7 @@ class Lexer(object):
|
|||
break
|
||||
yield (EOF, None)
|
||||
|
||||
|
||||
svg_lexer = Lexer(lexicon)
|
||||
|
||||
|
||||
|
|
@ -145,140 +154,148 @@ class SVGPathParser(object):
|
|||
def parse(self, text):
|
||||
""" Parse a string of SVG <path> data.
|
||||
"""
|
||||
next = self.lexer.lex(text).next
|
||||
token = next()
|
||||
return self.rule_svg_path(next, token)
|
||||
gen = self.lexer.lex(text)
|
||||
next_val_fn = partial(next, *(gen,))
|
||||
token = next_val_fn()
|
||||
return self.rule_svg_path(next_val_fn, token)
|
||||
|
||||
def rule_svg_path(self, next, token):
|
||||
def rule_svg_path(self, next_val_fn, token):
|
||||
commands = []
|
||||
while token[0] is not EOF:
|
||||
if token[0] != 'command':
|
||||
raise SyntaxError("expecting a command; got %r" % (token,))
|
||||
rule = self.command_dispatch[token[1]]
|
||||
command_group, token = rule(next, token)
|
||||
command_group, token = rule(next_val_fn, token)
|
||||
commands.append(command_group)
|
||||
return commands
|
||||
|
||||
def rule_closepath(self, next, token):
|
||||
def rule_closepath(self, next_val_fn, token):
|
||||
command = token[1]
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
return (command, []), token
|
||||
|
||||
def rule_moveto_or_lineto(self, next, token):
|
||||
def rule_moveto_or_lineto(self, next_val_fn, token):
|
||||
command = token[1]
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
coordinates = []
|
||||
while token[0] in self.number_tokens:
|
||||
pair, token = self.rule_coordinate_pair(next, token)
|
||||
pair, token = self.rule_coordinate_pair(next_val_fn, token)
|
||||
coordinates.extend(pair)
|
||||
return (command, coordinates), token
|
||||
|
||||
def rule_orthogonal_lineto(self, next, token):
|
||||
def rule_orthogonal_lineto(self, next_val_fn, token):
|
||||
command = token[1]
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
coordinates = []
|
||||
while token[0] in self.number_tokens:
|
||||
coord, token = self.rule_coordinate(next, token)
|
||||
coord, token = self.rule_coordinate(next_val_fn, token)
|
||||
coordinates.append(coord)
|
||||
return (command, coordinates), token
|
||||
|
||||
def rule_curveto3(self, next, token):
|
||||
def rule_curveto3(self, next_val_fn, token):
|
||||
command = token[1]
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
coordinates = []
|
||||
while token[0] in self.number_tokens:
|
||||
pair1, token = self.rule_coordinate_pair(next, token)
|
||||
pair2, token = self.rule_coordinate_pair(next, token)
|
||||
pair3, token = self.rule_coordinate_pair(next, token)
|
||||
pair1, token = self.rule_coordinate_pair(next_val_fn, token)
|
||||
pair2, token = self.rule_coordinate_pair(next_val_fn, token)
|
||||
pair3, token = self.rule_coordinate_pair(next_val_fn, token)
|
||||
coordinates.extend(pair1)
|
||||
coordinates.extend(pair2)
|
||||
coordinates.extend(pair3)
|
||||
return (command, coordinates), token
|
||||
|
||||
def rule_curveto2(self, next, token):
|
||||
def rule_curveto2(self, next_val_fn, token):
|
||||
command = token[1]
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
coordinates = []
|
||||
while token[0] in self.number_tokens:
|
||||
pair1, token = self.rule_coordinate_pair(next, token)
|
||||
pair2, token = self.rule_coordinate_pair(next, token)
|
||||
pair1, token = self.rule_coordinate_pair(next_val_fn, token)
|
||||
pair2, token = self.rule_coordinate_pair(next_val_fn, token)
|
||||
coordinates.extend(pair1)
|
||||
coordinates.extend(pair2)
|
||||
return (command, coordinates), token
|
||||
|
||||
def rule_curveto1(self, next, token):
|
||||
def rule_curveto1(self, next_val_fn, token):
|
||||
command = token[1]
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
coordinates = []
|
||||
while token[0] in self.number_tokens:
|
||||
pair1, token = self.rule_coordinate_pair(next, token)
|
||||
pair1, token = self.rule_coordinate_pair(next_val_fn, token)
|
||||
coordinates.extend(pair1)
|
||||
return (command, coordinates), token
|
||||
|
||||
def rule_elliptical_arc(self, next, token):
|
||||
def rule_elliptical_arc(self, next_val_fn, token):
|
||||
command = token[1]
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
arguments = []
|
||||
while token[0] in self.number_tokens:
|
||||
rx = Decimal(token[1]) * 1
|
||||
if rx < Decimal("0.0"):
|
||||
raise SyntaxError("expecting a nonnegative number; got %r" % (token,))
|
||||
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
if token[0] not in self.number_tokens:
|
||||
raise SyntaxError("expecting a number; got %r" % (token,))
|
||||
ry = Decimal(token[1]) * 1
|
||||
if ry < Decimal("0.0"):
|
||||
raise SyntaxError("expecting a nonnegative number; got %r" % (token,))
|
||||
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
if token[0] not in self.number_tokens:
|
||||
raise SyntaxError("expecting a number; got %r" % (token,))
|
||||
axis_rotation = Decimal(token[1]) * 1
|
||||
|
||||
token = next()
|
||||
if token[1] not in ('0', '1'):
|
||||
token = next_val_fn()
|
||||
if token[1][0] not in ('0', '1'):
|
||||
raise SyntaxError("expecting a boolean flag; got %r" % (token,))
|
||||
large_arc_flag = Decimal(token[1]) * 1
|
||||
large_arc_flag = Decimal(token[1][0]) * 1
|
||||
|
||||
token = next()
|
||||
if token[1] not in ('0', '1'):
|
||||
if len(token[1]) > 1:
|
||||
token = list(token)
|
||||
token[1] = token[1][1:]
|
||||
else:
|
||||
token = next_val_fn()
|
||||
if token[1][0] not in ('0', '1'):
|
||||
raise SyntaxError("expecting a boolean flag; got %r" % (token,))
|
||||
sweep_flag = Decimal(token[1]) * 1
|
||||
sweep_flag = Decimal(token[1][0]) * 1
|
||||
|
||||
token = next()
|
||||
if len(token[1]) > 1:
|
||||
token = list(token)
|
||||
token[1] = token[1][1:]
|
||||
else:
|
||||
token = next_val_fn()
|
||||
if token[0] not in self.number_tokens:
|
||||
raise SyntaxError("expecting a number; got %r" % (token,))
|
||||
x = Decimal(token[1]) * 1
|
||||
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
if token[0] not in self.number_tokens:
|
||||
raise SyntaxError("expecting a number; got %r" % (token,))
|
||||
y = Decimal(token[1]) * 1
|
||||
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
arguments.extend([rx, ry, axis_rotation, large_arc_flag, sweep_flag, x, y])
|
||||
|
||||
return (command, arguments), token
|
||||
|
||||
def rule_coordinate(self, next, token):
|
||||
def rule_coordinate(self, next_val_fn, token):
|
||||
if token[0] not in self.number_tokens:
|
||||
raise SyntaxError("expecting a number; got %r" % (token,))
|
||||
x = getcontext().create_decimal(token[1])
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
return x, token
|
||||
|
||||
|
||||
def rule_coordinate_pair(self, next, token):
|
||||
def rule_coordinate_pair(self, next_val_fn, token):
|
||||
# Inline these since this rule is so common.
|
||||
if token[0] not in self.number_tokens:
|
||||
raise SyntaxError("expecting a number; got %r" % (token,))
|
||||
x = getcontext().create_decimal(token[1])
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
if token[0] not in self.number_tokens:
|
||||
raise SyntaxError("expecting a number; got %r" % (token,))
|
||||
y = getcontext().create_decimal(token[1])
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
return [x, y], token
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,15 +56,22 @@ Multiple transformations are supported:
|
|||
In [12]: svg_transform_parser.parse('translate(30 -30) rotate(36)')
|
||||
Out[12]: [('translate', [30.0, -30.0]), ('rotate', [36.0])]
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import re
|
||||
from decimal import *
|
||||
from decimal import Decimal
|
||||
from functools import partial
|
||||
|
||||
from six.moves import range
|
||||
|
||||
|
||||
# Sentinel.
|
||||
class _EOF(object):
|
||||
|
||||
def __repr__(self):
|
||||
return 'EOF'
|
||||
|
||||
|
||||
EOF = _EOF()
|
||||
|
||||
lexicon = [
|
||||
|
|
@ -86,6 +93,7 @@ class Lexer(object):
|
|||
|
||||
http://www.gooli.org/blog/a-simple-lexer-in-python/
|
||||
"""
|
||||
|
||||
def __init__(self, lexicon):
|
||||
self.lexicon = lexicon
|
||||
parts = []
|
||||
|
|
@ -108,6 +116,7 @@ class Lexer(object):
|
|||
break
|
||||
yield (EOF, None)
|
||||
|
||||
|
||||
svg_lexer = Lexer(lexicon)
|
||||
|
||||
|
||||
|
|
@ -145,88 +154,90 @@ class SVGTransformationParser(object):
|
|||
def parse(self, text):
|
||||
""" Parse a string of SVG transform="" data.
|
||||
"""
|
||||
next = self.lexer.lex(text).next
|
||||
gen = self.lexer.lex(text)
|
||||
next_val_fn = partial(next, *(gen,))
|
||||
|
||||
commands = []
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
while token[0] is not EOF:
|
||||
command, token = self.rule_svg_transform(next, token)
|
||||
commands.append(command)
|
||||
command, token = self.rule_svg_transform(next_val_fn, token)
|
||||
commands.append(command)
|
||||
return commands
|
||||
|
||||
def rule_svg_transform(self, next, token):
|
||||
def rule_svg_transform(self, next_val_fn, token):
|
||||
if token[0] != 'command':
|
||||
raise SyntaxError("expecting a transformation type; got %r" % (token,))
|
||||
command = token[1]
|
||||
rule = self.command_dispatch[command]
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
if token[0] != 'coordstart':
|
||||
raise SyntaxError("expecting '('; got %r" % (token,))
|
||||
numbers, token = rule(next, token)
|
||||
numbers, token = rule(next_val_fn, token)
|
||||
if token[0] != 'coordend':
|
||||
raise SyntaxError("expecting ')'; got %r" % (token,))
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
return (command, numbers), token
|
||||
|
||||
def rule_1or2numbers(self, next, token):
|
||||
def rule_1or2numbers(self, next_val_fn, token):
|
||||
numbers = []
|
||||
# 1st number is mandatory
|
||||
token = next()
|
||||
number, token = self.rule_number(next, token)
|
||||
token = next_val_fn()
|
||||
number, token = self.rule_number(next_val_fn, token)
|
||||
numbers.append(number)
|
||||
# 2nd number is optional
|
||||
number, token = self.rule_optional_number(next, token)
|
||||
number, token = self.rule_optional_number(next_val_fn, token)
|
||||
if number is not None:
|
||||
numbers.append(number)
|
||||
|
||||
return numbers, token
|
||||
|
||||
def rule_1number(self, next, token):
|
||||
def rule_1number(self, next_val_fn, token):
|
||||
# this number is mandatory
|
||||
token = next()
|
||||
number, token = self.rule_number(next, token)
|
||||
token = next_val_fn()
|
||||
number, token = self.rule_number(next_val_fn, token)
|
||||
numbers = [number]
|
||||
return numbers, token
|
||||
|
||||
def rule_1or3numbers(self, next, token):
|
||||
def rule_1or3numbers(self, next_val_fn, token):
|
||||
numbers = []
|
||||
# 1st number is mandatory
|
||||
token = next()
|
||||
number, token = self.rule_number(next, token)
|
||||
token = next_val_fn()
|
||||
number, token = self.rule_number(next_val_fn, token)
|
||||
numbers.append(number)
|
||||
# 2nd number is optional
|
||||
number, token = self.rule_optional_number(next, token)
|
||||
number, token = self.rule_optional_number(next_val_fn, token)
|
||||
if number is not None:
|
||||
# but, if the 2nd number is provided, the 3rd is mandatory.
|
||||
# we can't have just 2.
|
||||
numbers.append(number)
|
||||
|
||||
number, token = self.rule_number(next, token)
|
||||
number, token = self.rule_number(next_val_fn, token)
|
||||
numbers.append(number)
|
||||
|
||||
return numbers, token
|
||||
|
||||
def rule_6numbers(self, next, token):
|
||||
def rule_6numbers(self, next_val_fn, token):
|
||||
numbers = []
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
# all numbers are mandatory
|
||||
for i in xrange(6):
|
||||
number, token = self.rule_number(next, token)
|
||||
for i in range(6):
|
||||
number, token = self.rule_number(next_val_fn, token)
|
||||
numbers.append(number)
|
||||
return numbers, token
|
||||
|
||||
def rule_number(self, next, token):
|
||||
def rule_number(self, next_val_fn, token):
|
||||
if token[0] not in self.number_tokens:
|
||||
raise SyntaxError("expecting a number; got %r" % (token,))
|
||||
x = Decimal(token[1]) * 1
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
return x, token
|
||||
|
||||
def rule_optional_number(self, next, token):
|
||||
def rule_optional_number(self, next_val_fn, token):
|
||||
if token[0] not in self.number_tokens:
|
||||
return None, token
|
||||
else:
|
||||
x = Decimal(token[1]) * 1
|
||||
token = next()
|
||||
token = next_val_fn()
|
||||
return x, token
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,25 +48,29 @@
|
|||
# | DASHMATCH | FUNCTION S* any* ')'
|
||||
# | '(' S* any* ')' | '[' S* any* ']' ] S*;
|
||||
|
||||
|
||||
def parseCssString(str):
|
||||
rules = []
|
||||
# first, split on } to get the rule chunks
|
||||
chunks = str.split('}')
|
||||
for chunk in chunks:
|
||||
# second, split on { to get the selector and the list of properties
|
||||
bits = chunk.split('{')
|
||||
if len(bits) != 2: continue
|
||||
rule = {}
|
||||
rule['selector'] = bits[0].strip()
|
||||
# third, split on ; to get the property declarations
|
||||
bites = bits[1].strip().split(';')
|
||||
if len(bites) < 1: continue
|
||||
props = {}
|
||||
for bite in bites:
|
||||
# fourth, split on : to get the property name and value
|
||||
nibbles = bite.strip().split(':')
|
||||
if len(nibbles) != 2: continue
|
||||
props[nibbles[0].strip()] = nibbles[1].strip()
|
||||
rule['properties'] = props
|
||||
rules.append(rule)
|
||||
return rules
|
||||
rules = []
|
||||
# first, split on } to get the rule chunks
|
||||
chunks = str.split('}')
|
||||
for chunk in chunks:
|
||||
# second, split on { to get the selector and the list of properties
|
||||
bits = chunk.split('{')
|
||||
if len(bits) != 2:
|
||||
continue
|
||||
rule = {}
|
||||
rule['selector'] = bits[0].strip()
|
||||
# third, split on ; to get the property declarations
|
||||
bites = bits[1].strip().split(';')
|
||||
if len(bites) < 1:
|
||||
continue
|
||||
props = {}
|
||||
for bite in bites:
|
||||
# fourth, split on : to get the property name and value
|
||||
nibbles = bite.strip().split(':')
|
||||
if len(nibbles) != 2:
|
||||
continue
|
||||
props[nibbles[0].strip()] = nibbles[1].strip()
|
||||
rule['properties'] = props
|
||||
rules.append(rule)
|
||||
return rules
|
||||
|
|
|
|||
121
setup.py
|
|
@ -1,64 +1,87 @@
|
|||
###############################################################################
|
||||
##
|
||||
## Copyright (C) 2013 Tavendo GmbH
|
||||
##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License");
|
||||
## you may not use this file except in compliance with the License.
|
||||
## You may obtain a copy of the License at
|
||||
##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0
|
||||
##
|
||||
## Unless required by applicable law or agreed to in writing, software
|
||||
## distributed under the License is distributed on an "AS IS" BASIS,
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
## See the License for the specific language governing permissions and
|
||||
## limitations under the License.
|
||||
##
|
||||
#
|
||||
# Copyright (C) 2013-2014 Tavendo GmbH
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
import os
|
||||
import re
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
LONGDESC = """
|
||||
Scour is a SVG optimizer/sanitizer that can be used to produce SVGs for Web deployment.
|
||||
Scour is an SVG optimizer/cleaner that reduces the size of scalable
|
||||
vector graphics by optimizing structure and removing unnecessary data.
|
||||
|
||||
It can be used to create streamlined vector graphics suitable for web
|
||||
deployment, publishing/sharing or further processing.
|
||||
|
||||
The goal of Scour is to output a file that renders identically at a
|
||||
fraction of the size by removing a lot of redundant information created
|
||||
by most SVG editors. Optimization options are typically lossless but can
|
||||
be tweaked for more aggressive cleaning.
|
||||
|
||||
Website
|
||||
- http://www.codedread.com/scour/ (original website)
|
||||
- https://github.com/oberstet/scour (today)
|
||||
- https://github.com/scour-project/scour (today)
|
||||
|
||||
Authors:
|
||||
- Jeff Schiller, Louis Simard (original authors)
|
||||
- Tobias Oberstein (maintainer)
|
||||
- Patrick Storz (maintainer)
|
||||
"""
|
||||
|
||||
setup (
|
||||
name = 'scour',
|
||||
version = '0.27',
|
||||
description = 'Scour SVG Optimizer',
|
||||
# long_description = open("README.md").read(),
|
||||
long_description = LONGDESC,
|
||||
license = 'Apache License 2.0',
|
||||
author = 'Jeff Schiller',
|
||||
author_email = 'codedread@gmail.com',
|
||||
url = 'https://github.com/oberstet/scour',
|
||||
platforms = ('Any'),
|
||||
install_requires = [],
|
||||
packages = find_packages(),
|
||||
zip_safe = True,
|
||||
entry_points = {
|
||||
'console_scripts': [
|
||||
'scour = scour.scour:run'
|
||||
]},
|
||||
classifiers = ["License :: OSI Approved :: Apache Software License",
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: Developers",
|
||||
"Intended Audience :: System Administrators",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Topic :: Internet",
|
||||
"Topic :: Software Development :: Build Tools",
|
||||
"Topic :: Software Development :: Pre-processors",
|
||||
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
|
||||
"Topic :: Utilities"],
|
||||
keywords = 'svg optimizer'
|
||||
VERSIONFILE = os.path.join(os.path.dirname(os.path.realpath(__file__)), "scour", "__init__.py")
|
||||
verstrline = open(VERSIONFILE, "rt").read()
|
||||
VSRE = r"^__version__ = u['\"]([^'\"]*)['\"]"
|
||||
mo = re.search(VSRE, verstrline, re.M)
|
||||
if mo:
|
||||
verstr = mo.group(1)
|
||||
else:
|
||||
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
|
||||
|
||||
|
||||
setup(
|
||||
name='scour',
|
||||
version=verstr,
|
||||
description='Scour SVG Optimizer',
|
||||
# long_description = open("README.md").read(),
|
||||
long_description=LONGDESC,
|
||||
license='Apache License 2.0',
|
||||
author='Jeff Schiller',
|
||||
author_email='codedread@gmail.com',
|
||||
url='https://github.com/scour-project/scour',
|
||||
platforms=('Any'),
|
||||
install_requires=['six>=1.9.0'],
|
||||
packages=find_packages(),
|
||||
zip_safe=True,
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'scour = scour.scour:run'
|
||||
]},
|
||||
classifiers=["License :: OSI Approved :: Apache Software License",
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: Developers",
|
||||
"Intended Audience :: System Administrators",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Topic :: Internet",
|
||||
"Topic :: Software Development :: Build Tools",
|
||||
"Topic :: Software Development :: Pre-processors",
|
||||
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
|
||||
"Topic :: Utilities"],
|
||||
keywords='svg optimizer'
|
||||
)
|
||||
|
|
|
|||
57
test_css.py
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Test Harness for Scour
|
||||
#
|
||||
# Copyright 2010 Jeff Schiller
|
||||
#
|
||||
# This file is part of Scour, http://www.codedread.com/scour/
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
from scour.yocto_css import parseCssString
|
||||
|
||||
|
||||
class Blank(unittest.TestCase):
|
||||
|
||||
def runTest(self):
|
||||
r = parseCssString('')
|
||||
self.assertEqual(len(r), 0, 'Blank string returned non-empty list')
|
||||
self.assertEqual(type(r), type([]), 'Blank string returned non list')
|
||||
|
||||
|
||||
class ElementSelector(unittest.TestCase):
|
||||
|
||||
def runTest(self):
|
||||
r = parseCssString('foo {}')
|
||||
self.assertEqual(len(r), 1, 'Element selector not returned')
|
||||
self.assertEqual(r[0]['selector'], 'foo', 'Selector for foo not returned')
|
||||
self.assertEqual(len(r[0]['properties']), 0, 'Property list for foo not empty')
|
||||
|
||||
|
||||
class ElementSelectorWithProperty(unittest.TestCase):
|
||||
|
||||
def runTest(self):
|
||||
r = parseCssString('foo { bar: baz}')
|
||||
self.assertEqual(len(r), 1, 'Element selector not returned')
|
||||
self.assertEqual(r[0]['selector'], 'foo', 'Selector for foo not returned')
|
||||
self.assertEqual(len(r[0]['properties']), 1, 'Property list for foo did not have 1')
|
||||
self.assertEqual(r[0]['properties']['bar'], 'baz', 'Property bar did not have baz value')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
2796
test_scour.py
Executable file
31
tox.ini
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
[tox]
|
||||
envlist =
|
||||
pypy
|
||||
py27
|
||||
py34
|
||||
py35
|
||||
py36
|
||||
py37
|
||||
py38
|
||||
py39
|
||||
py310
|
||||
flake8
|
||||
|
||||
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
six
|
||||
coverage
|
||||
|
||||
commands =
|
||||
scour --version
|
||||
coverage run --parallel-mode --source=scour test_scour.py
|
||||
|
||||
|
||||
[testenv:flake8]
|
||||
deps =
|
||||
flake8
|
||||
|
||||
commands =
|
||||
flake8 --max-line-length=119
|
||||
45
unittests/adobe.svg
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:x="http://ns.adobe.com/Extensibility/1.0/"
|
||||
xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/"
|
||||
xmlns:graph="http://ns.adobe.com/Graphs/1.0/"
|
||||
xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
|
||||
xmlns:f="http://ns.adobe.com/Flows/1.0/"
|
||||
xmlns:ir="http://ns.adobe.com/ImageReplacement/1.0/"
|
||||
xmlns:custom="http://ns.adobe.com/GenericCustomNamespace/1.0/"
|
||||
xmlns:xpath="http://ns.adobe.com/XPath/1.0/"
|
||||
xmlns:ok="A.namespace.we.want.left.in"
|
||||
i:viewOrigin="190.2959 599.1841" i:rulerOrigin="0 0" i:pageBounds="0 792 612 0">
|
||||
<x:foo>bar</x:foo>
|
||||
<i:foo>bar</i:foo>
|
||||
<graph:foo>bar</graph:foo>
|
||||
<a:foo>bar</a:foo>
|
||||
<f:foo>bar</f:foo>
|
||||
<ir:foo>bar</ir:foo>
|
||||
<custom:foo>bar</custom:foo>
|
||||
<xpath:foo>bar</xpath:foo>
|
||||
<variableSets xmlns="http://ns.adobe.com/Variables/1.0/">
|
||||
<variableSet varSetName="binding1" locked="none">
|
||||
<variables/>
|
||||
<v:sampleDataSets xmlns="http://ns.adobe.com/GenericCustomNamespace/1.0/" xmlns:v="http://ns.adobe.com/Variables/1.0/"/>
|
||||
</variableSet>
|
||||
</variableSets>
|
||||
<sfw xmlns="http://ns.adobe.com/SaveForWeb/1.0/">
|
||||
<slices/>
|
||||
<sliceSourceBounds y="191.664" x="190.296" width="225.72" height="407.52" bottomLeftOrigin="true"/>
|
||||
</sfw>
|
||||
<rect width="300" height="200" fill="green"
|
||||
x:baz="1"
|
||||
i:baz="1"
|
||||
graph:baz="1"
|
||||
a:baz="1"
|
||||
f:baz="1"
|
||||
ir:baz="1"
|
||||
custom:baz='1'
|
||||
xpath:baz="1"
|
||||
xmlns:v="http://ns.adobe.Variables/1.0/"
|
||||
v:baz="1"
|
||||
xmlns:sfw="http://ns.adobe.com/SaveForWeb/1.0/"
|
||||
sfw:baz="1"
|
||||
ok:baz="1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
23
unittests/cascading-default-attribute-removal.svg
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<path style="fill-rule:evenodd;stroke-linecap:butt;stroke-width:1.00;stroke:#000" d="m1,1z"/>
|
||||
<path style="fill-rule:nonzero;stroke-linecap:butt;stroke:#000" d="m1,1z"/>
|
||||
<g style="stroke:#f00;marker:none">
|
||||
<path style="marker-start:none;fill-rule:evenodd;stroke-linecap:butt" d="m1,1z"/>
|
||||
<path style="fill-rule:nonzero" d="m1,1z"/>
|
||||
<g style="fill:#f0f;text-anchor:stop;fill-rule:evenodd;stroke-linecap:round;marker:url(#nirvana)">
|
||||
<path style="marker-start:none;fill-rule:evenodd;stroke-linecap:butt" d="m1,1z"/>
|
||||
<path style="color:#000;fill-rule:nonzero;" d="m1,1z"/>
|
||||
<path d="m1,1z"/>
|
||||
</g>
|
||||
<g style="fill:#f0f;text-anchor:stop;fill-rule:evenodd;stroke-linecap:round;marker:url(#nirvana)">
|
||||
<path style="marker-start:none;fill-rule:evenodd;stroke-linecap:butt" d="m1,1z"/>
|
||||
<path style="color:#000;fill-rule:nonzero;" d="m1,1z"/>
|
||||
</g>
|
||||
<g style="text-anchor:stop;fill-rule:nonzero;marker:none;stroke-linecap:butt">
|
||||
<path style="marker-start:none;fill-rule:evenodd;stroke-linecap:butt" d="m1,1z"/>
|
||||
<path style="fill-rule:nonzero;" d="m1,1z"/>
|
||||
<path d="m1,1z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
6
unittests/cdata.svg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
alert('pb&j');
|
||||
]]></script>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 184 B |
11
unittests/collapse-gradients-gradientUnits.svg
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="g1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="blue" />
|
||||
<stop offset="1" stop-color="yellow" />
|
||||
</linearGradient>
|
||||
<radialGradient id="g2" xlink:href="#g1" cx="50%" cy="50%" r="30%" gradientUnits="objectBoundingBox"/>
|
||||
</defs>
|
||||
<rect fill="url(#g2)" width="200" height="200"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 507 B |
13
unittests/collapse-gradients-preserve-xlink-href.svg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="g1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="blue" />
|
||||
<stop offset="1" stop-color="yellow" />
|
||||
</linearGradient>
|
||||
<radialGradient id="g2" xlink:href="#g1" cx="100" cy="100" r="70"/>
|
||||
<radialGradient id="g3" xlink:href="#g2" cx="100" cy="100" r="70"/>
|
||||
</defs>
|
||||
<rect fill="url(#g1)" width="200" height="200"/>
|
||||
<rect fill="url(#g3)" width="200" height="200" y="200"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 599 B |
11
unittests/collapse-gradients.svg
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="grad1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" spreadMethod="reflect" gradientTransform="matrix(1,2,3,4,5,6)">
|
||||
<stop offset="0" stop-color="blue" />
|
||||
<stop offset="1" stop-color="yellow" />
|
||||
</linearGradient>
|
||||
<radialGradient id="grad2" xlink:href="#grad1" cx="100" cy="100" r="70"/>
|
||||
</defs>
|
||||
<rect fill="url(#grad2)" width="200" height="200"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 547 B |
4
unittests/collapse-same-path-points.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="210" height="210">
|
||||
<path stroke="yellow" fill="red" d="M100,100 L200.12345,200.12345 C215,205 185,195 200.12345,200.12345 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 281 B |
33
unittests/collapse-straight-path-segments.svg
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<marker id="dot">
|
||||
<circle r="5px"/>
|
||||
</marker>
|
||||
</defs>
|
||||
|
||||
<!-- h/v commands should be collapsed into a single h/v commands -->
|
||||
<path d="m0 0h10 20"/>
|
||||
<path d="m0 0v10 20"/>
|
||||
<path d="m0 0h10 0.5v10 0.5"/>
|
||||
<!-- h/v commands should not be collapsed if they have different direction -->
|
||||
<path d="m0 0h10 -1v10 -1"/>
|
||||
<!-- h/v commands should also be collapsed if only start/end markers are present -->
|
||||
<path d="m0 0h10 20" marker-start="url(#dot)" marker-end="url(#dot)"/>
|
||||
<path d="m0 0h10 20" style="marker-start:url(#dot);marker-end:url(#dot)"/>
|
||||
<!-- h/v commands should be preserved if intermediate markers are present -->
|
||||
<path d="m0 0h10 20" marker="url(#dot)"/>
|
||||
<path d="m0 0h10 20" marker-mid="url(#dot)"/>
|
||||
<path d="m0 0h10 20" style="marker:url(#dot)"/>
|
||||
<path d="m0 0h10 20" style="marker-mid:url(#dot)"/>
|
||||
|
||||
<!-- all consecutive lineto commands pointing into the sam direction
|
||||
should be collapsed into a single (implicit if possible) lineto command -->
|
||||
<path d="m 0 0 l 10 20 0.25 0.5 l 0.75 1.5 l 5 10 0.2 0.4 l 3 6 0.8 1.6 l 0 1 l 1 2 9 18"/>
|
||||
<!-- must not be collapsed (same slope, but different direction) -->
|
||||
<path d="m 0 0 10 10 -20 -20 l 10 10 -20 -20"/>
|
||||
<!-- first parameter pair of a moveto subpath must not be collapsed as it's not drawn on canvas -->
|
||||
<path d="m0 0 1 2 m 1 2 1 2l 1 2 m 1 2 1 2 1 2"/>
|
||||
<!-- real world example of straight path with multiple nodes -->
|
||||
<path d="m 6.3227953,7.1547422 10.6709787,5.9477588 9.20334,5.129731 22.977448,12.807101 30.447251,16.970601 7.898986,4.402712"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
12
unittests/color-formats.svg
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
<defs>
|
||||
<linearGradient id="g1" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0.5" stop-color="rgb(50.0%, 0%, .0%)" />
|
||||
</linearGradient>
|
||||
<solidColor id="c1" solid-color="lightgoldenrodyellow"/>
|
||||
</defs>
|
||||
<rect id="rect" width="100" height="100" fill="rgb(15,16,17)" stroke="darkgrey" />
|
||||
<circle id="circle" cx="100" cy="100" r="30" fill="url(#g1)" stroke="url(#c1)" />
|
||||
<ellipse id="ellipse" cx="100" cy="100" rx="30" ry="30" style="fill:#ffffff" fill="black" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 589 B |
10
unittests/comment-beside-xml-decl.svg
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<!-- Oh look a comment -->
|
||||
<!-- generated by foobar version 20120503 -->
|
||||
<!-- And another -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- This comment is meant to test whether removing a comment before <svg>
|
||||
messes up removing comments thereafter -->
|
||||
<!-- And this one is meant to test whether iteration works correctly in
|
||||
<svg> as well as the document element -->
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 448 B |
6
unittests/comments.svg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!-- Empty -->
|
||||
<!-- Comment #2 -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
</svg>
|
||||
<!-- After -->
|
||||
|
After Width: | Height: | Size: 121 B |
9
unittests/commonized-referenced-elements.svg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="g">
|
||||
<rect width="200" height="100" fill="#0f0"/>
|
||||
<rect width="200" height="100" fill="#0f0"/>
|
||||
<rect width="200" height="100" fill="#0f0"/>
|
||||
<circle id="e" r="20" fill="#0f0"/>
|
||||
</g>
|
||||
<use xlink:href="#e" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 324 B |
27
unittests/css-reference.svg
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<defs>
|
||||
<linearGradient id="g1">
|
||||
<stop offset="0" stop-color="red"/>
|
||||
<stop offset="1" stop-color="blue"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="g2">
|
||||
<stop offset="0" stop-color="green"/>
|
||||
<stop offset="1" stop-color="yellow"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<style type="text/css"><![CDATA[
|
||||
rect {
|
||||
stroke: red;
|
||||
stroke-width: 10;
|
||||
fill:url(#g1)
|
||||
}
|
||||
]]></style>
|
||||
|
||||
<style type="text/css">.circ { fill: none; stroke: url("#g2"); stroke-width: 15 }</style>
|
||||
|
||||
<rect height="300" width="300"/>
|
||||
<circle class="circ" cx="350" cy="350" r="40"/>
|
||||
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 691 B |
6
unittests/descriptive-elements-with-text.svg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<title>This is a title element with only text node children</title>
|
||||
<desc>This is a desc element with only text node children</desc>
|
||||
<metadata>This is a metadata element with only text node children</metadata>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 319 B |
7
unittests/doctype.svg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- comment -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
|
||||
<!ENTITY ns_svg "http://www.w3.org/2000/svg">
|
||||
<!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
|
||||
]>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/>
|
||||
|
After Width: | Height: | Size: 350 B |
13
unittests/dont-collapse-gradients.svg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="g1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="blue" />
|
||||
<stop offset="1" stop-color="yellow" />
|
||||
</linearGradient>
|
||||
<radialGradient id="g2" xlink:href="#g1" cx="100" cy="100" r="70"/>
|
||||
<radialGradient id="g3" xlink:href="#g1" cx="100" cy="100" r="70"/>
|
||||
</defs>
|
||||
<rect fill="url(#g2)" width="200" height="200"/>
|
||||
<rect fill="url(#g3)" width="200" height="200" y="200"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 599 B |
4
unittests/dont-convert-short-color-names.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<rect fill="red" width="100" height="100" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 149 B |
12
unittests/duplicate-gradient-stops-pct.svg
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
<defs>
|
||||
<linearGradient id="sea-gradient" x1="0" x2="0" y1="0" y2="1">
|
||||
<stop offset="0%" stop-color="lightgrey"/>
|
||||
<stop offset="0.5" stop-color="darkgrey"/>
|
||||
<stop offset="50%" stop-color="darkgrey"/>
|
||||
<stop offset="100%" stop-color="white"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect style="fill: url(#sea-gradient) rgb(0, 0, 0);" y="0" x="0" height="100" width="100"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 497 B |
19
unittests/duplicate-gradient-stops.svg
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="lingrad" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="red" />
|
||||
<stop offset="0.5" stop-color="blue" />
|
||||
<stop offset="0.5" stop-color="blue" />
|
||||
<stop offset="1.0" stop-color="green" />
|
||||
</linearGradient>
|
||||
<radialGradient id="radgrad">
|
||||
<stop offset="0" stop-color="red" />
|
||||
<stop offset="0.5" stop-color="blue" />
|
||||
<stop offset="0.5" stop-color="blue" />
|
||||
<stop offset="1.0" stop-color="green" />
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<rect width="300" height="300" fill="url(#lingrad)" />
|
||||
<rect width="300" height="300" fill="url(#radgrad)" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 740 B |
16
unittests/duplicate-gradients-update-style.svg
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="duplicate-one" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="blue" />
|
||||
<stop offset="1" stop-color="yellow" />
|
||||
</linearGradient>
|
||||
<linearGradient id="duplicate-two" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="blue" />
|
||||
<stop offset="1" stop-color="yellow" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect style="fill: url(#duplicate-one)" width="200" height="200"/>
|
||||
<rect style="fill: url(#duplicate-two)" width="200" height="200" y="200"/>
|
||||
<rect style="fill: url(#duplicate-two) #fff" width="200" height="200" y="200"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 788 B |
5
unittests/empty-descriptive-elements.svg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<title></title>
|
||||
<desc></desc>
|
||||
<metadata></metadata>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 106 B |
7
unittests/empty-g.svg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<g/>
|
||||
<g transform="translate(10,10)">
|
||||
<rect width="300" height="200" fill="green" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 203 B |
4
unittests/empty-style.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" ?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<style id="style1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 97 B |
4
unittests/encoding-iso-8859-15.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-15" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<desc>áèîäöüߤ¦¨´¸¼½¾</desc>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 139 B |
19
unittests/encoding-utf8.svg
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<desc id="hello">Hello in many languages:
|
||||
ar: أهلا
|
||||
bn: হ্যালো
|
||||
el: Χαίρετε
|
||||
en: Hello
|
||||
hi: नमस्ते
|
||||
iw: שלום
|
||||
ja: こんにちは
|
||||
km: ជំរាបសួរ
|
||||
ml: ഹലോ
|
||||
ru: Здравствуйте
|
||||
ur: ہیلو
|
||||
zh: 您好</desc>
|
||||
<desc id="common">“”‘’–—…‐‒°©®™•½¼¾⅓⅔†‡µ¢£€«»♠♣♥♦¿<EFBFBD></desc>
|
||||
<desc id="math">:-×÷±∞π∅≤≥≠≈∧∨∩∪∈∀∃∄∑∏←↑→↓↔↕↖↗↘↙↺↻⇒⇔</desc>
|
||||
<desc id="supersub">⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁽⁾ⁿⁱ₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎</desc>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 731 B |
8
unittests/entities.svg
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
a="'"
|
||||
b='"'
|
||||
c="''""
|
||||
d='""''
|
||||
e='''""'
|
||||
/>
|
||||
|
After Width: | Height: | Size: 144 B |
5
unittests/fill-none.svg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<path style="fill: none; fill-rule: nonzero; fill-opacity: 0.5;" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" />
|
||||
<path style="fill: black; fill-rule: evenodd; fill-opacity: 0.5;" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 430 B |
66
unittests/flowtext-less.svg
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="210mm"
|
||||
height="297mm"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="flowtext-less.svg">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.35"
|
||||
inkscape:cx="350"
|
||||
inkscape:cy="520"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1559"
|
||||
inkscape:window-height="876"
|
||||
inkscape:window-x="41"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
|
||||
x="142.85715"
|
||||
y="638.07648"
|
||||
id="text2997"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan2999"
|
||||
x="142.85715"
|
||||
y="638.07648">abcd</tspan></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
78
unittests/flowtext.svg
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="210mm"
|
||||
height="297mm"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="Neues Dokument 1">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.35"
|
||||
inkscape:cx="350"
|
||||
inkscape:cy="520"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="936"
|
||||
inkscape:window-height="631"
|
||||
inkscape:window-x="41"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="0" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<flowRoot
|
||||
xml:space="preserve"
|
||||
id="flowRoot2985"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"><flowRegion
|
||||
id="flowRegion2987"><rect
|
||||
id="rect2989"
|
||||
width="480"
|
||||
height="262.85715"
|
||||
x="45.714287"
|
||||
y="218.07646" /></flowRegion><flowPara
|
||||
id="flowPara2991">sfdadasd</flowPara><flowPara
|
||||
id="flowPara2993">asdasd</flowPara><flowPara
|
||||
id="flowPara2995">adsa</flowPara></flowRoot> <text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
|
||||
x="142.85715"
|
||||
y="638.07648"
|
||||
id="text2997"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan2999"
|
||||
x="142.85715"
|
||||
y="638.07648">abcd</tspan></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
4
unittests/font-styles.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<rect style="font-size:20px" width="100" height="100" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 162 B |
31
unittests/full-descriptive-elements.svg
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<title xmlns:mytitle="http://example.org/mytitle">
|
||||
<mytitle:title>This is an example SVG file</mytitle:title>
|
||||
<mytitle:desc>Unit test for Scour's --remove-titles option</mytitle:desc>
|
||||
</title>
|
||||
<desc xmlns:mydesc="http://example.org/mydesc">
|
||||
<mydesc:title>This is an example SVG file</mydesc:title>
|
||||
<mydesc:para>Unit test for Scour's
|
||||
<mydesc:emph>--remove-descriptions</mydesc:emph> option</mydesc:para>
|
||||
</desc>
|
||||
<metadata>
|
||||
<rdf:RDF
|
||||
xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:rdfs = "http://www.w3.org/2000/01/rdf-schema#"
|
||||
xmlns:dc = "http://purl.org/dc/elements/1.1/" >
|
||||
<rdf:Description about="http://example.org/myfoo"
|
||||
dc:title="MyFoo"
|
||||
dc:description="Unit test for Scour's --remove-metadata option"
|
||||
dc:publisher="No One"
|
||||
dc:date="2010-06-09"
|
||||
dc:format="image/svg+xml"
|
||||
dc:language="en" >
|
||||
<dc:creator>
|
||||
<rdf:Bag>
|
||||
<rdf:li>No One</rdf:li>
|
||||
</rdf:Bag>
|
||||
</dc:creator>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
21
unittests/gradient-default-attrs.svg
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<linearGradient id="grad1" x1="0" y1='0' x2='100%' y2='0.0' gradientUnits="objectBoundingBox" spreadMethod="pad">
|
||||
<stop offset="0" stop-color="black"/>
|
||||
<stop offset="1" stop-color="white"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="grad1b" x2='1.0' gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="black"/>
|
||||
<stop offset="1" stop-color="white"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="grad1c" x2='1' gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="black"/>
|
||||
<stop offset="1" stop-color="white"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="grad2" xlink:href="#grad1" cx="50%" cy="0.5" r="50%" fx="50%" fy="0.5"/>
|
||||
|
||||
<rect width="100" height="100" fill="url(#grad1)"/>
|
||||
<rect width="100" height="100" fill="url(#grad1b)"/>
|
||||
<rect width="100" height="100" fill="url(#grad1c)"/>
|
||||
<rect width="50" height="50" fill="url(#grad2)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1 KiB |
6
unittests/group-creation.svg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<rect fill="red" stroke="blue" x="0" y="0" width="4" height="4" />
|
||||
<rect fill="red" stroke="blue" x="8" y="0" width="4" height="4" />
|
||||
<rect fill="red" stroke="blue" x="16" y="0" width="4" height="4" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 317 B |
8
unittests/group-no-creation-tspan.svg
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg height="100" width="100" xmlns="http://www.w3.org/2000/svg" >
|
||||
<text>
|
||||
<tspan x="10" y="30" style="font-family:sans-serif">text1</tspan>
|
||||
<tspan x="10" y="50" style="font-family:sans-serif">text2</tspan>
|
||||
<tspan x="10" y="70" style="font-family:sans-serif">text3</tspan>
|
||||
</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 350 B |
6
unittests/group-no-creation.svg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<rect fill="green" stroke="blue" x="0" y="0" width="4" height="4" />
|
||||
<rect fill="yellow" stroke="red" x="8" y="0" width="4" height="4" />
|
||||
<rect fill="blue" stroke="red" x="16" y="0" width="4" height="4" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 321 B |
13
unittests/group-sibling-merge-crash.svg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" viewBox="0 0 141.732 141.732" xml:space="preserve">
|
||||
<g>
|
||||
<g clip-path="url(#SVGID_2_)">
|
||||
<path d="M1,1" fill="#fdebc8" stroke="#000" stroke-width=".5" stroke-miterlimit="10"/>
|
||||
</g>
|
||||
<g clip-path="url(#SVGID_2_)">
|
||||
<g>
|
||||
<path opacity=".5" clip-path="url(#SVGID_4_)" fill="#fff" d="M1,1"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 528 B |
29
unittests/group-sibling-merge.svg
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<desc>Produced by GNUPLOT 5.2 patchlevel 8</desc>
|
||||
<rect width="900" height="600" fill="none"/>
|
||||
<g color="black" fill="none">
|
||||
<path d="m88.5 564h9m777.5 0h-9" stroke="#000"/>
|
||||
<g transform="translate(80.2,567.9)" fill="#000" font-family="Arial" font-size="12" text-anchor="end">
|
||||
<text><tspan font-family="Arial">0</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
<g color="black" fill="none">
|
||||
<path d="m88.5 473h9m777.5 0h-9" stroke="#000"/>
|
||||
<g transform="translate(80.2,476.9)" fill="#000" font-family="Arial" font-size="12" text-anchor="end">
|
||||
<text><tspan font-family="Arial">5000</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
<g color="black" fill="none">
|
||||
<path d="m88.5 382h9m777.5 0h-9" stroke="#000"/>
|
||||
<g transform="translate(80.2,385.9)" fill="#000" font-family="Arial" font-size="12" text-anchor="end">
|
||||
<text><tspan font-family="Arial">10000</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
<g color="black" fill="none">
|
||||
<path d="m88.5 291h9m777.5 0h-9" stroke="#000"/>
|
||||
<g transform="translate(80.2,294.9)" fill="#000" font-family="Arial" font-size="12" text-anchor="end">
|
||||
<text><tspan font-family="Arial">15000</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
18
unittests/groups-in-switch-with-id.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:example="http://www.example.com/olfactory-feedback/0.1"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<switch>
|
||||
<foreignObject requiredExtensions="http://www.example.com/olfactory-feedback/0.1" x="0" y="0" width="1" height="1">
|
||||
<example:odor xlink:href="#odor1423">
|
||||
</example:odor>
|
||||
</foreignObject>
|
||||
<g id="dsfargeg">
|
||||
<rect width="300" height="200" fill="green" />
|
||||
<circle cx="200" cy="100" r="50" fill="yellow" />
|
||||
</g>
|
||||
</switch>
|
||||
<defs>
|
||||
<example:odor id="odor1423" fill="grape"/>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 609 B |
18
unittests/groups-in-switch.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:example="http://www.example.com/olfactory-feedback/0.1"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<switch>
|
||||
<foreignObject requiredExtensions="http://www.example.com/olfactory-feedback/0.1" x="0" y="0" width="1" height="1">
|
||||
<example:odor xlink:href="#odor1423">
|
||||
</example:odor>
|
||||
</foreignObject>
|
||||
<g>
|
||||
<rect width="300" height="200" fill="green" />
|
||||
<circle cx="200" cy="100" r="50" fill="yellow" />
|
||||
</g>
|
||||
</switch>
|
||||
<defs>
|
||||
<example:odor id="odor1423" fill="grape"/>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 595 B |
13
unittests/groups-with-title-desc.svg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<title>Group 1</title>
|
||||
<rect width="300" height="200" fill="green" />
|
||||
<circle cx="200" cy="100" r="50" fill="yellow" />
|
||||
</g>
|
||||
<g>
|
||||
<desc>Group 1</desc>
|
||||
<rect width="300" height="200" fill="green" />
|
||||
<circle cx="200" cy="100" r="50" fill="yellow" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 365 B |
8
unittests/ids-protect.svg
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="110" width="100">
|
||||
<text id="text1" x="10" y="20">Text 1</text>
|
||||
<text id="text2" x="10" y="40">Text 2</text>
|
||||
<text id="text3" x="10" y="60">Text 3</text>
|
||||
<text id="text_custom" x="10" y="80">Text custom</text>
|
||||
<text id="my_text1" x="10" y="100">My text</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 358 B |
11
unittests/ids-to-strip.svg
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" id="boo">
|
||||
<defs>
|
||||
<title id="title1">Fooey</title>
|
||||
<rect id='r1' />
|
||||
<linearGradient id="Polka_Dot_Pattern">
|
||||
<stop offset="0.5" stop-color="blue" id="stop1234"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect id='r2' fill="url(#Polka_Dot_Pattern)" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 348 B |
12
unittests/ids.svg
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg id="svg1" xmlns="http://www.w3.org/2000/svg" height="100" width="100" viewBox="0 0 100 100">
|
||||
<defs>
|
||||
<linearGradient id="linearGradient1">
|
||||
<stop offset="0"/>
|
||||
<stop offset="1" stop-color="blue"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="layer1">
|
||||
<rect id="rect1" height="50" width="50" x="10" y="10" fill="url(#linearGradient1)"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 425 B |
12
unittests/important-groups-in-defs.svg
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<g>
|
||||
<linearGradient id="g1">
|
||||
<stop offset="0" stop-color="blue"/>
|
||||
<stop offset="1" stop-color="red"/>
|
||||
</linearGradient>
|
||||
</g>
|
||||
</defs>
|
||||
<rect fill="url(#g1)" width="100" height="100" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 305 B |
7
unittests/inkscape.svg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:foo="http://www.inkscape.org/namespaces/inkscape"
|
||||
inkscape:version="0.46" version="1.0">
|
||||
<inkscape:perspective inkscape:vp_x="0 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" id="perspective3104"/>
|
||||
<rect width="300" height="200" fill="green" inkscape:collect="always" foo:bar="1"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 545 B |
2
unittests/minimal.svg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"/>
|
||||
|
After Width: | Height: | Size: 81 B |
10
unittests/move-common-attributes-to-grandparent.svg
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="grampa" fill-opacity="0.4">
|
||||
<g stroke-opacity="0.8">
|
||||
<rect fill="#0F0" stroke="#0F0" stroke-width="5" width="100" height="300"/>
|
||||
<rect fill="#0F0" width="200" height="100" />
|
||||
</g>
|
||||
<circle fill="#0F0" stroke="0F0" cx="50" cy="50" r="20" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 368 B |
13
unittests/move-common-attributes-to-parent.svg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<g fill-opacity="0.4">
|
||||
<rect fill="#0F0" stroke="#0F0" stroke-width="5" width="100" height="300"/>
|
||||
<rect fill="#0F0" width="200" height="100" />
|
||||
<circle fill="#0F0" stroke="0F0" cx="50" cy="50" r="20" />
|
||||
</g>
|
||||
<text>Hello
|
||||
<tspan font-style="italic">World!</tspan>
|
||||
Goodbye
|
||||
<tspan font-style="italic">Cruel World!</tspan>
|
||||
</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 436 B |
14
unittests/nested-defs.svg
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<defs>
|
||||
<linearGradient id="linearGradient662">
|
||||
<stop style="stop-color:#000000;stop-opacity:1" offset="0"/>
|
||||
<stop style="stop-color:#0000ff;stop-opacity:1" offset="1"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<linearGradient x1="120.22393" y1="156.07137" x2="119.33763" y2="162.87338" id="linearGradient3211" xlink:href="#linearGradient662" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.789103,0,0,1.131232,0.366124,452.0845)"/>
|
||||
</defs>
|
||||
<path d="m50 50h50v50h-50z" fill="url(#linearGradient3211)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 732 B |
9
unittests/nested-useless-groups.svg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<g transform="translate(50,50)">
|
||||
<rect width="300" height="200" fill="green" />
|
||||
<circle cx="200" cy="100" r="50" fill="yellow" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 253 B |
50
unittests/newlines.svg
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
|
||||
>
|
||||
|
||||
|
||||
|
||||
<!-- this file has pretty messed up formatting --> <rect width="100" height="100"/>
|
||||
<rect width="100" height="100"/>
|
||||
<rect width="100" height="100"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<rect width="100" height="100"/>
|
||||
<rect width="100" height="100"/>
|
||||
<rect width="100" height="100"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- we have mixed newline
|
||||
characters, carriage returns
and both of them
|
||||
as well as tabs and spaces
|
||||
-->
|
||||
|
||||
<rect width="100" height="100"/><rect width="100" height="100"/> <rect width="100" height="100"/>
|
||||
|
||||
<rect width="100" height="100"/>
<rect width="100" height="100"/> <rect width="100" height="100"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<rect width="100" height="100"/> <rect width="100" height="100"/>
|
||||
|
||||
|
||||
</svg>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- OMG, really? -->
|
||||
|
After Width: | Height: | Size: 889 B |
8
unittests/no-collapse-lines.svg
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48"
|
||||
viewBox="0.1 -0.333 125 125" xml:space="preserve">
|
||||
<g id="Layer_1_2_">
|
||||
<path d="M24.599,16.542v27.584l-4.994-1.033L0,60.671l52.687,63.612l51.361-40.729l20.844-18.664c0,0-23.527-4.871-27.404-5.673
|
||||
c0-4.4,0-47.951,0-47.951L43.071,0L24.599,16.542z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 415 B |
12
unittests/orient-marker.svg
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<marker id="m1" orient="auto">
|
||||
<rect width="200" height="100"/>
|
||||
</marker>
|
||||
<marker id="m2" orient="0">
|
||||
<rect width="200" height="100"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<line x2="100" y2="100" style="marker-start:url(#m1);marker-end:url(#m2)" stroke="#000" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 414 B |
12
unittests/overflow-marker.svg
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<marker id="m1" style="overflow:visible">
|
||||
<rect width="200" height="100"/>
|
||||
</marker>
|
||||
<marker id="m2" style="overflow:hidden">
|
||||
<rect width="200" height="100"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<line x2="100" y2="100" style="marker-start:url(#m1);marker-end:url(#m2)" stroke="#000" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 438 B |
9
unittests/overflow-svg.svg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="overflow:visible">
|
||||
<svg style="overflow:hidden">
|
||||
<line x2="100" y2="100" stroke="#000" />
|
||||
</svg>
|
||||
<svg style="overflow:visible">
|
||||
<line x2="100" y2="100" stroke="#000" />
|
||||
</svg>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 344 B |
4
unittests/path-abs-to-rel.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M 385,201 V181 l100,-50 h20 C 505.43501,223.44223 659.42238,164.82405 714.32160,-0.0015300000 C 649.90356,227.13187 497.48814,312.46353 371.30643,277.40123 C 245.12472,242.33893 157.17674,250.88268 121.69357,12.440270 C 211.69357,149.44027 323.87473,190.08578 385.88362,201.47812 z " fill="blue"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 416 B |
6
unittests/path-bez-optimize.svg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg version="1.1" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
|
||||
<path id="path1" d="m10,100c50-50,50,50,100,0,50-50,50,50,100,0" fill="none" stroke="blue" stroke-width="5"/>
|
||||
<path id="path2a" d="m200,200c0,0 200,100 200,0" fill="none" stroke="red" stroke-width="5"/>
|
||||
<path id="path2b" d="m0,300s200-100 200,0c0,0 200,100 200,0" fill="none" stroke="green" stroke-width="5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 455 B |
8
unittests/path-command-rewrites.svg
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m100 100 l200 100 m0 0z" />
|
||||
<path d="m100 100 v200 m0 0 100 100z" />
|
||||
<path d="m100 100 v200 m0 0m0 0 2-1-2 1z" />
|
||||
<path d="m100 100 v200 m0 0 3-5-5 3m0 0 2-1-2 1z" />
|
||||
<path d="m100 100 v200 m0 0 3-5-5 3zm0 0 2-1-2 1z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 310 B |
7
unittests/path-elliptical-flags.svg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg viewBox="-100 -50 300 150" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m0 0a100 50 0 0 0 100 50" fill="none" stroke="#000"/>
|
||||
<path d="m0 0a100 50 0 0 0100 50" fill="none" stroke="green"/>
|
||||
<path d="m0 0a100 50 0 00 100 50" fill="none" stroke="blue"/>
|
||||
<path d="m0 0a100 50 0 00100 50" fill="none" stroke="red"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 370 B |
4
unittests/path-implicit-line.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<path stroke="#000" d="M100,100,100,200 M300,100,100,100 M300,200,300,100" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 193 B |
4
unittests/path-line-optimize.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
<path d="M 100,100 l200,0 l0,100 h-200 l0,0 z" fill="blue" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 203 B |
4
unittests/path-no-optimize.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="210" height="210">
|
||||
<path stroke="yellow" fill="red" d="M100,100 L200.12345,200.12345 C215,205 185,195 200.12,200.12 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 275 B |
13
unittests/path-precision-control-points.svg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m 1.11 2.22 3.33 4.44
|
||||
M 0 0
|
||||
C 1.11 2.22 3.33 4.44 5.55 6.66
|
||||
c 1.11 2.22 3.33 4.44 5.55 6.66 1.11 2.22 3.33 4.44 5.55 6.66
|
||||
M 0 0
|
||||
S 1.11 2.22 3.33 4.44
|
||||
s 1.11 2.22 3.33 4.44 1.11 2.22 3.33 4.44
|
||||
M 0 0
|
||||
Q 1.11 2.22 3.33 4.44
|
||||
q 1.11 2.22 3.33 4.44 1.11 2.22 3.33 4.44" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 463 B |
11
unittests/path-precision.svg
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<path id="p0" d="M 100.0000001 99.9999999 h100.01 v123456789.123456789 h-100 z" />
|
||||
|
||||
<path id="p1" d="m 1 21 321 4321 54321 654321 " />
|
||||
<path id="p2" d="m 1.0 21.0 321.0 4321.0 54321.0 654321.0" />
|
||||
<path id="p3" d="m 01 021 0321 04321 054321 0654321 " />
|
||||
<path id="p4" d="m -1 -21 -321 -4321 -54321 -654321 " />
|
||||
|
||||
<path id="p6" d="m 123.456 101.001 -123.456 -101.001" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 517 B |
4
unittests/path-quad-optimize.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg version="1.1" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m10,100q50-50,100,0,50,50,100,0" fill="none" stroke="blue" stroke-width="5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 228 B |
8
unittests/path-simple-triangle.svg
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
<path d="M 300. 100 h-50-1.5E+2
|
||||
|
||||
|
||||
|
||||
l100.00000,2000.0E-01 z" fill="red" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 222 B |
4
unittests/path-sn.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1781 1142">
|
||||
<path d="m 0,0 l 2.e-4,0 z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 159 B |
4
unittests/path-truncate-zeros-calc.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="5 0 3 3">
|
||||
<path stroke="blue" stroke-width="0.01" fill="none" d="M5.81,0 H5.91000" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 199 B |
4
unittests/path-truncate-zeros.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
<path d="M300.0000, -100.1 z" fill="red" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 163 B |
4
unittests/path-use-scientific-notation.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="5 0 3 3">
|
||||
<path d="M10000,0" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 145 B |
10
unittests/path-with-caps.svg
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<path id="none" d="m0 0 0 0"/>
|
||||
<path id="attr_butt" d="m0 0 0 0" stroke-linecap="butt"/>
|
||||
<path id="attr_round" d="m0 0 0 0" stroke-linecap="round"/>
|
||||
<path id="attr_square" d="m0 0 0 0" stroke-linecap="square"/>
|
||||
<path id="style_butt" d="m0 0 0 0" style="stroke-linecap:butt"/>
|
||||
<path id="style_round" d="m0 0 0 0" style="stroke-linecap:round"/>
|
||||
<path id="style_square" d="m0 0 0 0" style="stroke-linecap:square"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 522 B |
4
unittests/path-with-closepath.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill="none" stroke="#000" d="M10,10h100v100h-100z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 162 B |
4
unittests/polygon-coord-neg-first.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<polygon points="-100,-100,100-100,100-100-100,-100-100,200" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 156 B |
4
unittests/polygon-coord-neg.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<polygon points="100,-100,100-100,100-100-100,-100-100,200" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 155 B |
4
unittests/polygon-coord.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<polygon fill="blue" points="10000,50" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 146 B |
5
unittests/polygon.svg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<polygon fill="blue" points="50,50 150,50 150,150 50,150 +5e1,500.00e-1" />
|
||||
<polygon fill="green" points="200,50 300,50 300,150 200,150" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 245 B |
4
unittests/polyline-coord-neg-first.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<polyline points="-100,-100,100-100,100-100-100,-100-100,200" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 157 B |
4
unittests/polyline-coord-neg.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<polyline points="100,-100,100-100,100-100-100,-100-100,200" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 156 B |
4
unittests/polyline-coord.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<polyline fill="blue" points="10000,50" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 147 B |
11
unittests/protection.svg
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<path id="path1" d="m1,1z"/>
|
||||
<path id="path2" d="m1,1z"/>
|
||||
<path id="path3" d="m1,1z"/>
|
||||
<path id="path4" d="m1,1z"/>
|
||||
<path id="p:mypath1" d="m1,1z"/>
|
||||
<path id="p_mypath1" d="m1,1z"/>
|
||||
<path id="otherpath" d="m1,1z"/>
|
||||
<use xlink:href="#path1"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 403 B |
10
unittests/quot-in-url.svg
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="g" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0" stop-color="#0F0" />
|
||||
<stop offset="1" stop-color="#00F"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="100" height="100" fill="url("#g")"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 372 B |
5
unittests/quotes-in-styles.svg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<style>use[id="t"] {font-size: small}</style>
|
||||
<text id="t" style="font-family:'Times New Roman'"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 188 B |