mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Add support for text before edge baseline
This commit is contained in:
parent
4ce55ae0d2
commit
26868e4cab
1 changed files with 6 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue