setting line height for text element in raphael

2019-04-07 14:54发布

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

标签: svg raphael
1条回答
We Are One
2楼-- · 2019-04-07 15:51

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.

查看更多
登录 后发表回答