Problem with dy in text->tspan
Posted: 2019-09-17T09:12:54-07:00
Hello!
This code works fine in browsers and inkscape.
It gives the following picture.
But with imagick 3.4.4 (Imagick compiled with ImageMagick version - ImageMagick 6.9.10-43 Q16 x86_64 2019-05-02, Imagick using ImageMagick library version - ImageMagick 6.9.10-64 Q16 x86_64 2019-09-09, ImageMagick release date - 2019-09-09) it gives not correct result.
It seems that <tspan> in <text> “knows” nothing about non zero value of “dy” in it’s parent. If “dy” in <text> replace with equvalent tranform=”translate(0,-…)” code will work ok.
Is it a bug? If it is, then in what version of imagemagick it is fixed?
If anybody has version older then in my question, please check this problem.
php script and svg file are attached.
source svg file
php script for testing
This code works fine in browsers and inkscape.
Code: Select all
<svg …>
<line x1="-60" y1="0" x2="60" y2="0" transform="translate(100,160)" style="…"/>
<circle r="5" transform="translate(100,160)" style="…"/>
<text x="100" y="160" dy="-30" style="… text-anchor:middle; …">
X
<tspan dy="20" style="…">
Y
</tspan>
</text>
</svg>
Is it a bug? If it is, then in what version of imagemagick it is fixed?
If anybody has version older then in my question, please check this problem.
php script and svg file are attached.
source svg file
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200" version="1.1">
<line x1="-60" y1="0" x2="60" y2="0" transform="translate(100,160)" style="stroke:#000000"/>
<circle r="5" transform="translate(100,160)" style="fill:#000000"/>
<text x="100" y="160" dy="-30" style="font-size:100px; font-family: Times New Roman; text-anchor:middle; fill:#000000;stroke:none"
>X<tspan dy="20" style="font-size:60px">Y</tspan></text>
</svg>
Code: Select all
<?php
$fileName = 'tspan.svg';
$svg = file_get_contents($fileName);
$image = new Imagick();
$image->readImageBlob($svg);
$image->setImageFormat('png');
$image->setImageType(Imagick::IMGTYPE_GRAYSCALE);
header('Content-type: image/png');
echo $image;
$image->clear();
$image->destroy();
exit;