From 66d63b4541d3736569beca5a09dfe91b1a6669ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6?= <1936472877@qq.com> Date: Sat, 11 Jan 2025 11:43:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B6=85=E5=87=BA=E6=96=87=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/canvas/canvas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/canvas/canvas.js b/models/canvas/canvas.js index 92f6ac6..c30ce7d 100644 --- a/models/canvas/canvas.js +++ b/models/canvas/canvas.js @@ -87,8 +87,8 @@ export function toImage (canvas) { */ export function shortenText (ctx, text, maxWidth, replace = '...') { if (!text) return '' - maxWidth -= ctx.measureText(replace).width if (ctx.measureText(text).width < maxWidth) return text + maxWidth -= ctx.measureText(replace).width while (ctx.measureText(text).width > maxWidth) { text = text.slice(0, -1) }