Setting line height for text element in raphael

I would like to increase the line height for a multi-line text element generated with raphael. This does not work:

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

How can I do that? Thanks

+6
svg raphael
source share
1 answer

You can do the following, but it’s not very pretty and destroys 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 produce overlapping lines of text with default font settings.

If I open a better way, I will update my answer.

+6
source share

All Articles