This commit is contained in:
Dragon Fire
2024-05-03 11:00:28 -04:00
parent 50cb56bf1b
commit 4554be2def
2 changed files with 4 additions and 4 deletions
@@ -70,12 +70,12 @@ module.exports = class SpongebobTimeCardCommand extends Command {
let fontSize = 345;
ctx.font = this.client.fonts.get('Spongeboytt1.ttf').toCanvasString(fontSize);
let lines = wrapText(ctx, text.toUpperCase(), 1800);
let metrics = ctx.measureText(lines.join('\n'));
let longestLine = lines.sort((a, b) => ctx.measureText(b).width - ctx.measureText(a).width)[0];
let heightMetric = measureTextHeightWithBreaks(ctx, lines.join('\n'));
while (metrics.width > 1800 || heightMetric > 1000) {
while (longestLine > 1800 || heightMetric > 1000) {
fontSize -= 10;
ctx.font = this.client.fonts.get('Spongeboytt1.ttf').toCanvasString(fontSize);
metrics = ctx.measureText(lines.join('\n'));
longestLine = lines.sort((a, b) => ctx.measureText(b).width - ctx.measureText(a).width)[0];
heightMetric = measureTextHeightWithBreaks(ctx, lines.join('\n'));
lines = wrapText(ctx, text.toUpperCase(), 1800);
}
+1 -1
View File
@@ -69,7 +69,7 @@ module.exports = class TweetCommand extends Command {
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(23);
const lines = wrapText(ctx, text, 710, true);
const metrics = measureTextHeightWithBreaks(ctx, lines.join('\n'));
const linesLen = metrics + 15;
const linesLen = metrics + 10;
canvas.height += linesLen;
let imageHeight = 0;
ctx.fillStyle = 'black';