Raphael.Export icon indicating copy to clipboard operation
Raphael.Export copied to clipboard

The value of the attribute "dy" of the element <tspan> got changed after conversion

Open techhunter opened this issue 13 years ago • 3 comments

Before calling Paper.toSVG()

<tspan dy="4">Test </tspan>

After

<tspan dy="NaN">Test </tspan>

What am i missing?

techhunter avatar Jun 25 '12 07:06 techhunter

Most likely you're not missing anything but stumbled upon a bug. I'll look into it when I get the chance and report back.

AliasIO avatar Jun 25 '12 23:06 AliasIO

/**
* Computes tspan dy using font size. This formula was empircally determined
* using a best-fit line. Works well in both VML and SVG browsers.
* @param fontSize number
* @return number
*/
function computeTSpanDy(fontSize, line, lines) {
    if ( fontSize === null ) fontSize = 10;
    else if(typeof fontSize == 'string') fontSize = parseInt(fontSize);
    //return fontSize * 4.5 / 13
    return fontSize * 4.5 / 13 * ( line - .2 - lines / 2 ) * 3.5;
}

yukaizhao avatar Jul 13 '12 03:07 yukaizhao

Thanks for that, I haven't had the time to look at it myself yet.

AliasIO avatar Jul 13 '12 05:07 AliasIO