代码如下:
<svg:svg width="${w}" height="${h}" id="${processId}">
<svg:rect x="0" y="0" width="${w}" height="${h}" class="outer drag-start"/>
<svg:rect x="3" y="3" width="${w-6}" height="${h-6}" class="inner"/>
<svg:text text-anchor="middle" x="50%" y="50%" dominant-baseline="central">${text}</svg:text>
</svg:svg>
怎样设置最后一个 text 容器的字体大小以及能根据文字长度进行换行处理?
字体大小最好通过css来设置。
至于一般所期望的换行,当前标准的 svg 做不到。不过,可以嵌入html来解决。
参考:svg文字自动换行