function drawMultiText(svg, [x, y], text, options = {}) {
options = addDefaults(options, DEFAULT_STYLE);
options = addDefaults(options, {
maxCharsPerLine: 30,
lineSpacing: 1
});
const lineList = text.split(' ').reduce(function(lineList, word) {
if (lineList.length === 0) {
lineList = [word];
} else if (
lineList[lineList.length - 1].length + word.length + 1 <=
options.maxCharsPerLine
) {
lineList[lineList.length - 1] += ' ' + word;
} else {
lineList.push([word]);
}
return lineList;
}, []);
const n = lineList.length;
lineList.forEach(function(line, i) {
const y1 = y + options.fontSize * options.lineSpacing * (i - (n - 1) / 2);
drawText(svg, [x, y1], line, options);
});
}