Use Chirp font

This commit is contained in:
Dragon Fire
2024-04-21 13:54:31 -04:00
parent 0de35ee7e9
commit 2ef5f45fa8
3 changed files with 16 additions and 16 deletions
Binary file not shown.
Binary file not shown.
+16 -16
View File
@@ -61,7 +61,7 @@ module.exports = class TweetCommand extends Command {
const base2 = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'tweet', 'bg-2.png'));
const canvas = createCanvas(base1.width, base1.height + base2.height);
const ctx = canvas.getContext('2d');
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(23);
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(23);
const lines = await wrapText(ctx, text, 710);
const lineBreakLen = text.split('\n').length;
const linesLen = (23 * lines.length)
@@ -82,7 +82,7 @@ module.exports = class TweetCommand extends Command {
const base2StartY = base1.height + linesLen;
ctx.drawImage(base2, 0, base2StartY);
ctx.textBaseline = 'top';
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpBold.ttf').toCanvasString(18);
ctx.fillStyle = 'white';
ctx.fillText(userData.name, 80, 88);
if (userData.verified) {
@@ -92,67 +92,67 @@ module.exports = class TweetCommand extends Command {
const nameLen = ctx.measureText(userData.name).width;
ctx.drawImage(verified, 80 + nameLen + 3, 90, 20, 20);
}
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(17);
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(17);
ctx.fillStyle = '#71767b';
ctx.fillText(`@${userData.screenName}`, 80, 113);
ctx.fillStyle = 'white';
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(23);
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(23);
ctx.fillText(lines.join('\n'), 17, 160);
ctx.fillStyle = '#71767b';
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(18);
const time = moment().format('h:mm A ∙ MMMM D, YYYY ∙');
ctx.fillText(time, 18, base2StartY + 12);
const timeLen = ctx.measureText(time).width;
ctx.fillStyle = 'white';
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpBold.ttf').toCanvasString(18);
ctx.fillText(formatNumberK(views), 18 + timeLen + 6, base2StartY + 12);
const viewsLen = ctx.measureText(formatNumberK(views)).width;
ctx.fillStyle = '#71767b';
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(18);
ctx.fillText('Views', 18 + timeLen + 6 + viewsLen + 6, base2StartY + 12);
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(16);
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(16);
ctx.fillText(formatNumberK(replies), 64, base2StartY + 145);
ctx.fillText(formatNumberK(likes), 415, base2StartY + 145);
ctx.fillText(formatNumberK(retweets + quotTweets), 242, base2StartY + 145);
ctx.fillText(formatNumberK(bookmarks), 588, base2StartY + 145);
let currentLen = 17;
ctx.fillStyle = 'white';
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpBold.ttf').toCanvasString(18);
ctx.fillText(formatNumberK(retweets), currentLen, base2StartY + 75);
currentLen += ctx.measureText(formatNumberK(retweets)).width;
currentLen += 5;
ctx.fillStyle = '#71767b';
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(18);
ctx.fillText('Reposts', currentLen, base2StartY + 75);
currentLen += ctx.measureText('Reposts').width;
currentLen += 10;
ctx.fillStyle = 'white';
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpBold.ttf').toCanvasString(18);
ctx.fillText(formatNumberK(quotTweets), currentLen, base2StartY + 75);
currentLen += ctx.measureText(formatNumberK(quotTweets)).width;
currentLen += 5;
ctx.fillStyle = '#71767b';
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(18);
ctx.fillText('Quotes', currentLen, base2StartY + 75);
currentLen += ctx.measureText('Quotes').width;
currentLen += 10;
ctx.fillStyle = 'white';
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpBold.ttf').toCanvasString(18);
ctx.fillText(formatNumberK(likes), currentLen, base2StartY + 75);
currentLen += ctx.measureText(formatNumberK(likes)).width;
currentLen += 5;
ctx.fillStyle = '#71767b';
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(18);
ctx.fillText('Likes', currentLen, base2StartY + 75);
currentLen += ctx.measureText('Likes').width;
currentLen += 10;
ctx.fillStyle = 'white';
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpBold.ttf').toCanvasString(18);
ctx.fillText(formatNumberK(bookmarks), currentLen, base2StartY + 75);
currentLen += ctx.measureText(formatNumberK(bookmarks)).width;
currentLen += 5;
ctx.fillStyle = '#71767b';
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(18);
ctx.fillText('Bookmarks', currentLen, base2StartY + 75);
ctx.beginPath();
ctx.arc(17 + 26, 84 + 26, 26, 0, Math.PI * 2);