From dfa215b296f49d0818ffdae5ffc363923d0684a4 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 3 May 2024 00:48:14 -0400 Subject: [PATCH] Make font use actual canvas height --- commands/edit-image-text/font.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/edit-image-text/font.js b/commands/edit-image-text/font.js index 8b7b7fbb..42251587 100644 --- a/commands/edit-image-text/font.js +++ b/commands/edit-image-text/font.js @@ -38,7 +38,8 @@ module.exports = class FontCommand extends Command { ctxPre.font = this.client.fonts.get(font.filename).toCanvasString(50); const len = ctxPre.measureText(text); const lines = wrapText(ctxPre, text, 950); - const canvas = createCanvas(Math.min(len.width + 50, 1000), 50 + (50 * lines.length) + (20 * lines.length)); + const height = len.actualBoundingBoxAscent + len.actualBoundingBoxDescent; + const canvas = createCanvas(Math.min(len.width + 50, 1000), 50 + height); const ctx = canvas.getContext('2d'); ctx.font = this.client.fonts.get(font.filename).toCanvasString(50); ctx.textBaseline = 'top';