Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting line height for text element in raphael

Tags:

svg

raphael

I'd like to increase the line height for a multiline text element generated with raphael. This does not appear to work:

text_element.attr({"line-height": "16" });

How can this be done? Thanks

like image 284
tks Avatar asked Mar 25 '12 03:03

tks


1 Answers

You can do the following, but it's not pretty and breaks the encapsulation provided by Raphael. Consider the following:

text_element = r.text(10, 10, "Text in\nRaphael\nis a pain");

text_element.node.childNodes[0].setAttribute('dy', 0);
text_element.node.childNodes[1].setAttribute('dy', 5);
text_element.node.childNodes[2].setAttribute('dy', 5);

This will yield overlapping lines of text with the default font settings.

If I discover a better way, I'll update my answer.

like image 53
M. Anthony Aiello Avatar answered Oct 04 '22 21:10

M. Anthony Aiello