From 26868e4cab690816966243a4bb86125b1214e14b Mon Sep 17 00:00:00 2001 From: DD Date: Tue, 22 May 2018 11:02:32 -0400 Subject: [PATCH] Add support for text before edge baseline --- src/svg/SvgImport.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/svg/SvgImport.js b/src/svg/SvgImport.js index a7cc3e0d..038627b2 100644 --- a/src/svg/SvgImport.js +++ b/src/svg/SvgImport.js @@ -303,6 +303,7 @@ new function() { // Scratch-specific: Do not use x/y attributes because they break multiline usage. var fontSize = parseFloat(node.getAttribute("font-size")); + var alignmentBaseline = node.getAttribute("alignment-baseline"); if (node.childElementCount === 0) { var text = new PointText(); text.setContent(node.textContent.trim() || ''); @@ -333,8 +334,12 @@ new function() { } var text = new PointText(); if (!isNaN(fontSize)) text.setFontSize(fontSize); - text.setContent(lines.join('\n') || ''); text.setLeading(text.fontSize * spacing); + if (alignmentBaseline === 'text-before-edge') { + text.setContent(' '); // No content results in 0 height + text.translate(0, text.bounds.height); + } + text.setContent(lines.join('\n') || ''); return text; } }