Set preserve spaces, and insert spaces on blank lines when exporting text from paint. This makes render show the right thing.

This commit is contained in:
DD Liu 2018-12-18 16:43:09 -05:00
parent f69748fc06
commit f6b8f8e309

View file

@ -265,6 +265,7 @@ new function() {
var node = SvgElement.create('text', getTransform(item._matrix, false), var node = SvgElement.create('text', getTransform(item._matrix, false),
formatter); formatter);
node.setAttribute('font-size', item.fontSize); node.setAttribute('font-size', item.fontSize);
node.setAttribute('xml:space', 'preserve');
for (var i = 0; i < item._lines.length; i++) { for (var i = 0; i < item._lines.length; i++) {
// Scratch-specific: Use <tspan> for multiline text, // Scratch-specific: Use <tspan> for multiline text,
// right now only supports left justified (x=0) // right now only supports left justified (x=0)
@ -272,7 +273,7 @@ new function() {
x: '0', x: '0',
dy: i === 0 ? '0' : item.getLeading() + 'px' dy: i === 0 ? '0' : item.getLeading() + 'px'
}, formatter); }, formatter);
tspanNode.textContent = item._lines[i]; tspanNode.textContent = item._lines[i] ? item._lines[i] : ' ';
node.appendChild(tspanNode); node.appendChild(tspanNode);
} }
return node; return node;