在拉斐尔中设置文本元素的行高 [英] setting line height for text element in raphael

查看:95
本文介绍了在拉斐尔中设置文本元素的行高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想增加用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" });

这怎么办?谢谢

推荐答案

您可以执行以下操作,但它并不漂亮,并且破坏了Raphael提供的封装.请考虑以下内容:

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.

这篇关于在拉斐尔中设置文本元素的行高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆