* Fix: hang when inserting text with characters which do not fit into the canvas

This commit is contained in:
Sync1211 2022-05-18 13:10:21 +02:00
parent ccef4062fd
commit 17d4678f75
No known key found for this signature in database
GPG Key ID: B8878699435E69EC

View File

@ -478,7 +478,13 @@ class CanvasController {
ctx.font = canvasFont;
while (ctx.measureText(text).width > maxWidth) {
let line;
[line, text] = wrapText(text, getMaxCharsPerLine(text, ctx));
let maxChars = getMaxCharsPerLine(text, ctx);
if (maxChars == 0) {
lines.push(text.slice(0, 1));
text = text.slice(1, text.length);
continue;
}
[line, text] = wrapText(text, maxChars);
lines.push(line);
}
lines.push(text);