From 6ae739e797611bb0ea98f9892d360408a00759f6 Mon Sep 17 00:00:00 2001 From: skuqre <74248935+skuqre@users.noreply.github.com> Date: Tue, 12 Dec 2023 19:59:52 +0800 Subject: [PATCH] i think i've perfected it --- src/scripts/blabla.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scripts/blabla.js b/src/scripts/blabla.js index 8db7a78..828e42b 100644 --- a/src/scripts/blabla.js +++ b/src/scripts/blabla.js @@ -154,8 +154,8 @@ function generateBlabla() { ctx.letterSpacing = '-0.8px'; // ? let width = ctx.measureText(item.message).width; - let actualWidth = width + 22 * 2 > 418 ? 418 - 22 * 2 : width + 22 * 2; - let textWidth = actualWidth; + let actualWidth = width + 22 * 2 > 418 ? 418 : width + 22 * 2; + let textWidth = actualWidth - 22 * 2; let lines = getLinesForParagraphs(ctx, item.message, textWidth); let height = lines.length > 1 ? 19 + ((31) * (lines.length + 1)) : 81; @@ -410,7 +410,7 @@ function getLines(ctx, text, maxWidth) { for (var i = 1; i < words.length; i++) { var word = words[i]; var width = ctx.measureText(currentLine + " " + word).width; - if (width < maxWidth) { + if (width <= maxWidth) { currentLine += " " + word; } else { lines.push(currentLine);