setting line height for text element in raphael

你说的曾经没有我的故事 提交于 2019-12-06 01:48:02

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/9857659/setting-line-height-for-text-element-in-raphael

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!