mirror of
https://github.com/NaitLee/Cat-Printer.git
synced 2025-05-18 08:10:24 -07:00
* Fix: hang when inserting text with characters which do not fit into the canvas
This commit is contained in:
parent
ccef4062fd
commit
17d4678f75
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user