From 17d4678f758de40dfeda60d5a626e08fbc07a265 Mon Sep 17 00:00:00 2001 From: Sync1211 Date: Wed, 18 May 2022 13:10:21 +0200 Subject: [PATCH] * Fix: hang when inserting text with characters which do not fit into the canvas --- www/main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/main.js b/www/main.js index 54cc91e..7ca2151 100644 --- a/www/main.js +++ b/www/main.js @@ -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);