Skip to content

Commit

Permalink
Add document type for proper SVG rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
The Simple Designers authored and uyab committed Feb 27, 2018
1 parent 929d7e5 commit 9070478
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Avatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function toSvg()
$radius = ($this->width - $this->borderSize) / 2;
$center = $this->width / 2;

$svg = '<svg width="'.$this->width.'" height="'.$this->height.'">';
$svg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" width="'.$this->width.'" height="'.$this->height.'">';

if ($this->shape == 'square') {
$svg .= '<rect x="'.$x
Expand Down
4 changes: 2 additions & 2 deletions tests/AvatarPhpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function it_can_generate_file()
*/
public function it_can_generate_circle_svg()
{
$expected = '<svg width="100" height="100">';
$expected = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" width="100" height="100">';
$expected .= '<circle cx="50" cy="50" r="45" stroke="yellow" stroke-width="10" fill="red" />';
$expected .= '<text x="50" y="50" font-size="24" fill="white" alignment-baseline="middle" text-anchor="middle">AB</text>';
$expected .= '</svg>';
Expand All @@ -197,7 +197,7 @@ public function it_can_generate_circle_svg()
*/
public function it_can_generate_rectangle_svg()
{
$expected = '<svg width="100" height="100">';
$expected = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" width="100" height="100">';
$expected .= '<rect x="5" y="5" width="90" height="90" stroke="yellow" stroke-width="10" fill="red" />';
$expected .= '<text x="50" y="50" font-size="24" fill="white" alignment-baseline="middle" text-anchor="middle">AB</text>';
$expected .= '</svg>';
Expand Down

0 comments on commit 9070478

Please sign in to comment.