Skip to content

Commit 3607b29

Browse files
committed
properly handle empty lines, removed console log.
1 parent d51ccfa commit 3607b29

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/core/text-rendering/TextLayoutEngine.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,25 @@ export const wrapText = (
180180

181181
for (let i = 0; i < lines.length; i++) {
182182
const line = lines[i];
183-
if (line === undefined || line.length === 0) {
183+
if (line === undefined) {
184184
continue;
185185
}
186-
[wrappedLine, remainingLines, hasRemainingText] = wrapLine(
187-
measureText,
188-
line,
189-
fontFamily,
190-
maxWidth,
191-
letterSpacing,
192-
spaceWidth,
193-
overflowSuffix,
194-
wordBreak,
195-
remainingLines,
196-
hasMaxLines,
197-
);
186+
187+
[wrappedLine, remainingLines, hasRemainingText] =
188+
line.length > 0
189+
? wrapLine(
190+
measureText,
191+
line,
192+
fontFamily,
193+
maxWidth,
194+
letterSpacing,
195+
spaceWidth,
196+
overflowSuffix,
197+
wordBreak,
198+
remainingLines,
199+
hasMaxLines,
200+
)
201+
: [[['', 0, 0, 0]], remainingLines, i < lines.length - 1];
198202

199203
remainingLines--;
200204
wrappedLines.push(...wrappedLine);
@@ -361,8 +365,6 @@ export const wrapLine = (
361365
}
362366
}
363367

364-
console.log('remaining lines', remainingLines);
365-
366368
// Add the last line if it has content
367369
if (currentLine.length > 0 && hasMaxLines === true && remainingLines === 0) {
368370
currentLine = truncateLineWithSuffix(

0 commit comments

Comments
 (0)