From 1303e7d1f6e32b95f9a7e790a3859523206663c4 Mon Sep 17 00:00:00 2001 From: Supositware Date: Sat, 2 Mar 2019 19:27:16 +0100 Subject: [PATCH] Don't resize the font --- commands/images/nolight.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/commands/images/nolight.js b/commands/images/nolight.js index 19f4485b..9e566cba 100644 --- a/commands/images/nolight.js +++ b/commands/images/nolight.js @@ -32,28 +32,13 @@ class nolightCommand extends Command { .then(loadingmsg => loadingmsg.delete(2000)); const canvas = createCanvas(400, 400); - const applyText = (canvas, text) => { - const ctx = canvas.getContext('2d'); - - // Declare a base size of the font - let fontSize = 70; - - do { - // Assign the font to the context and decrement it so it can be measured again - ctx.font = `${fontSize -= 10}px ubuntu`; - } while (ctx.measureText(text).width > 700 - 300); - - // Return the result to use in the actual canvas - return ctx.font; - }; - const ctx = canvas.getContext('2d'); const { body: buffer } = await superagent.get('https://cdn.discordapp.com/attachments/484013245158522909/551078672132734988/Untitled.png').catch(() => { return message.channel.send('An error as occured, please try again'); }); const bg = await loadImage(buffer); ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); - ctx.font = applyText(canvas, text); + ctx.font = '70px ubuntu'; ctx.fillStyle = '#FFFFFF'; ctx.fillText(text, canvas.width / 10, canvas.height / 9);