mozman / svgwrite

Python Package to write SVG files (UNMAINTAINED)
Other
543 stars 97 forks source link

Symbol #111

Open Nickleaton opened 2 years ago

Nickleaton commented 2 years ago
 <symbol id="myDot" width="10" height="10" viewBox="0 0 2 2">
    <circle cx="1" cy="1" r="1" />
  </symbol>

https://developer.mozilla.org/en-US/docs/Web/SVG/Element/symbol

The mozilla docs imply you should be able to use width and height on a symbol.

import unittest

from svgwrite.container import Symbol

class TestSymbolHeightWidth(unittest.TestCase):

    def test_symbol(self):
        symbol = Symbol(id_="myDot", viewBox="0 0 2 2")
        self.assertIsNotNone(symbol)

    def test_size(self):
        symbol = Symbol(id_="myDot", viewBox="0 0 2 2", size=(10, 10))
        self.assertIsNotNone(symbol)

    def test_height_width(self):
        symbol = Symbol(id_="myDot", viewBox="0 0 2 2", height=100, width=100)
        self.assertIsNotNone(symbol)

if __name__ == '__main__':  # pragma: no cover
    unittest.main()
Nickleaton commented 2 years ago

PS. Nice library

brodokk commented 2 years ago

Sadly I think this enter in the new feature category while being the library not respecting the specs and since the last version new feature support have been stopped.

I could make a pull request anyway but not sure it will be accepted.

Also in this library, your test with the height and width will not be accepted I think since most of the class use size as a parameter and then setup the height and width parameter while initializing the object.

brodokk commented 2 years ago

After looking at the specification that this library use (https://svgwrite.readthedocs.io/en/latest/reference.html#svg-implementation-status) I see there only two versions supported, SVG1.1 and SVG1.2Tiny.

For SVG1.1 the height and width are not supported https://www.w3.org/TR/SVG11/struct.html#SymbolElement And for SVG1.2Tiny I don't see any reference.

So for me this is actually a big feature since it would mean to have a version special for the documentation on Mozilla (I only test the example code given in the Mozilla documentation on Firefox so I am not sure for it to work on other web browser)