From 21775bd33b07a5481af01d7ec3f466c05bf11fe2 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 4 May 2020 14:52:19 -0400 Subject: [PATCH] Scale text in skyrim skill --- commands/edit-meme/skyrim-skill.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/commands/edit-meme/skyrim-skill.js b/commands/edit-meme/skyrim-skill.js index c4594810..00440653 100644 --- a/commands/edit-meme/skyrim-skill.js +++ b/commands/edit-meme/skyrim-skill.js @@ -36,7 +36,7 @@ module.exports = class SkyrimSkillCommand extends Command { key: 'skill', prompt: 'What skill should be used?', type: 'string', - max: 10, + max: 15, parse: skill => skill.toUpperCase() }, { @@ -60,7 +60,12 @@ module.exports = class SkyrimSkillCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(plate, 0, height + 1); - ctx.font = 'normal bold 77px Futura'; + ctx.font = '77px Futura'; + let fontSize = 77; + while (ctx.measureText(text).width > 310) { + fontSize -= 1; + ctx.font = `${fontSize}px Futura`; + } ctx.textAlign = 'center'; ctx.textBaseline = 'top'; ctx.fillStyle = 'black';