Reputation: 252
I would like to draw text with SVG.JS and preserve whitespace
var draw = SVG('drawing')
var text = draw.text("040: .P .E .L 01 ")
just prints:
040: .P .E .L 01
I was suggested
this.el.lines.each(function() {
this.exportAttr({
'xml:space': 'preserve'
})
})
but this doesn't seem to work, as https://raw.github.com/wout/svg.js/master/dist/svg.js doesn't contain exportAttr
.
Upvotes: 0
Views: 419
Reputation: 2577
I see my suggestion was wrong because it targets the export plugin. It should be this of course:
var text = draw.text(' with a lot of white t e s p a c e')
text.lines.attr('xml:space', 'preserve', 'http://www.w3.org/XML/1998/namespace')
Upvotes: 1