我想获得拉斐尔生成文本的宽度,包括空格键的空间。然而,我发现
text=Canvas.paper.text(wordPos, linePos, word).attr({"font-size": fontSize,
"font-weight":TextParams.fontWeight, "fill":TextParams.color, "text-anchor":"start"});
console.log('text.getBBox().width (w/o space)='+text.getBBox().width);
word+=' ';
text=Canvas.paper.text(wordPos, linePos, word).attr({"font-size": fontSize,
"font-weight":TextParams.fontWeight, "fill":TextParams.color, "text-anchor":"start"});
console.log('text.getBBox().width (with space)='+text.getBBox().width);
返回
text.getBBox().width (w/o space)=51.125
text.getBBox().width (with space)=51.125
有没有办法获得包括空格在内的文本宽度?