Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Text 创建svg文本多行,其中一行为空行_Text_Svg_Raphael_Multiline - Fatal编程技术网

Text 创建svg文本多行,其中一行为空行

Text 创建svg文本多行,其中一行为空行,text,svg,raphael,multiline,Text,Svg,Raphael,Multiline,我使用with for each line创建SVG文本。 文本有许多行,其中一行是空行,如下所示: this is text line 1 this is text line 3 上面的示例是一个有三行的文本,其中一行是空的 问题是SVG文本只显示两行而不是三行(第一行和结束行,没有中间行) 请看这里: 有人有办法让它显示三行吗 注意:我正在使用Raphael JS创建这些文本。默认情况下,空白在html和svg中被压缩,因此\n\n\n变为\n。此外,如果根本没有文本,则忽略中间行。x

我使用with for each line创建SVG文本。 文本有许多行,其中一行是空行,如下所示:

this is text line 1


this is text line 3
上面的示例是一个有三行的文本,其中一行是空的

问题是SVG文本只显示两行而不是三行(第一行和结束行,没有中间行)

请看这里:

有人有办法让它显示三行吗


注意:我正在使用Raphael JS创建这些文本。

默认情况下,空白在html和svg中被压缩,因此\n\n\n变为\n。此外,如果根本没有文本,则忽略中间行。xml:space=“preserve”停止SVG中的空白压缩,额外的空间使中间行存在

var $svg = Raphael('container', 400, 400);
var $text = "this is line 1\n \nthis is line 3";
$svg.canvas.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space","preserve");
$svg.text(50, 100, $text);

默认情况下,在html和svg中压缩空白,因此\n\n\n变为\n。此外,如果根本没有文本,则忽略中间行。xml:space=“preserve”停止SVG中的空白压缩,额外的空间使中间行存在

var $svg = Raphael('container', 400, 400);
var $text = "this is line 1\n \nthis is line 3";
$svg.canvas.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space","preserve");
$svg.text(50, 100, $text);