diff --git a/src/Svg/Document.php b/src/Svg/Document.php index 309875b..3d6e80d 100644 --- a/src/Svg/Document.php +++ b/src/Svg/Document.php @@ -23,6 +23,7 @@ use Svg\Tag\Polyline; use Svg\Tag\Rect; use Svg\Tag\Stop; +use Svg\Tag\Symbol; use Svg\Tag\Text; use Svg\Tag\StyleTag; use Svg\Tag\UseTag; @@ -322,10 +323,14 @@ private function _tagStart($parser, $name, $attributes) break; case 'g': - case 'symbol': $tag = new Group($this, $name); break; + case 'symbol': + $this->inDefs = true; + $tag = new Symbol($this, $name); + break; + case 'clippath': $tag = new ClipPath($this, $name); break; @@ -378,6 +383,11 @@ function _tagEnd($parser, $name) $this->inDefs = false; return; + case 'symbol': + $this->inDefs = false; + $tag = array_pop($this->stack); + break; + case 'svg': case 'path': case 'rect': @@ -393,7 +403,6 @@ function _tagEnd($parser, $name) case 'style': case 'text': case 'g': - case 'symbol': case 'clippath': case 'use': case 'a': diff --git a/src/Svg/Tag/Symbol.php b/src/Svg/Tag/Symbol.php new file mode 100644 index 0000000..d00e7ab --- /dev/null +++ b/src/Svg/Tag/Symbol.php @@ -0,0 +1,34 @@ + + * @license GNU LGPLv3+ http://www.gnu.org/copyleft/lesser.html + */ + +namespace Svg\Tag; + +use Svg\Style; + +class Symbol extends AbstractTag +{ + protected function before($attributes) + { + $surface = $this->document->getSurface(); + + $surface->save(); + + $style = $this->makeStyle($attributes); + + $this->setStyle($style); + $surface->setStyle($style); + + $this->applyViewbox($attributes); + $this->applyTransform($attributes); + } + + protected function after() + { + $this->document->getSurface()->restore(); + } +} \ No newline at end of file