mirror of
https://github.com/penpot/penpot.git
synced 2025-07-26 21:09:27 +02:00
🐛 Fix justify text is stretched
This commit is contained in:
parent
1b7ea6ed53
commit
4ca6a89e6f
3 changed files with 15 additions and 6 deletions
|
@ -21,7 +21,7 @@ goog.scope(function () {
|
|||
return [...range.getClientRects()].filter((r) => r.width > 0);
|
||||
}
|
||||
|
||||
self.parse_text_nodes = function(parent, textNode) {
|
||||
self.parse_text_nodes = function(parent, textNode, textAlign) {
|
||||
const content = textNode.textContent;
|
||||
const textSize = content.length;
|
||||
|
||||
|
@ -38,13 +38,14 @@ goog.scope(function () {
|
|||
|
||||
while (to < textSize) {
|
||||
const rects = getRangeRects(textNode, from, to + 1);
|
||||
const splitByWords = textAlign == "justify" && content[to].trim() == "";
|
||||
|
||||
if (rects.length > 1 && safeguard) {
|
||||
from++;
|
||||
to++;
|
||||
safeguard = false;
|
||||
|
||||
} else if (rects.length > 1) {
|
||||
} else if (rects.length > 1 || splitByWords) {
|
||||
const position = prevRect;
|
||||
|
||||
result.push({
|
||||
|
@ -53,6 +54,10 @@ goog.scope(function () {
|
|||
text: current
|
||||
});
|
||||
|
||||
if (splitByWords) {
|
||||
to++;
|
||||
}
|
||||
|
||||
from = to;
|
||||
current = "";
|
||||
safeguard = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue