FIX: Wrap text properly

This fixes a bug where if you were wrapping text,
the first word was repeated.

We really need tests!
This commit is contained in:
Nicolás Hatcher
2025-03-03 19:44:23 +01:00
committed by Nicolás Hatcher Andrés
parent 532386b448
commit 90763048bc

View File

@@ -101,7 +101,8 @@ function computeWrappedLines(
for (const line of rawLines) {
const words = line.split(" ");
let currentLine = words[0];
for (const word of words) {
for (let i = 1; i < words.length; i += 1) {
const word = words[i];
const testLine = `${currentLine} ${word}`;
const textWidth = context.measureText(testLine).width;
if (textWidth < width) {