Automattic / Automattic/node-canvas

font not load

Open
#1,552 0 comments 1 reaction 0 assignees View on GitHub
Text & Fonts
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

![image](https://user-images.githubusercontent.com/40305210/78796915-4c0b3380-79b7-11ea-9865-4ca36ef2d153.png)
i get this error but i have apt install fron done
-----------------------------
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 sans-serif`;
// Compare pixel width of the text to the canvas minus the approximate avatar size
} while (ctx.measureText(text).width > canvas.width - 300);

// Return the result to use in the actual canvas
return ctx.font;
};

bot.on('guildMemberAdd', async member => {
const channel = member.guild.channels.find("id", "695339638059040869");
// const channel = member.guild.channels.find(ch => ch.name === 'member-log');
if (!channel) return;

const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');

const background = await Canvas.loadImage('./wallpaper.jpg');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);

// Slightly smaller text placed above the member's display name
ctx.font = '28px Arial';
ctx.fillStyle = '#ffffff';
ctx.fillText('Welcome to the server,', canvas.width / 2.5, canvas.height / 3.5);

// Add an exclamation point here and below
ctx.font = applyText(canvas, `${member.displayName}!`);
ctx.fillStyle = '#ffffff';
ctx.fillText(`${member.displayName}!`, canvas.width / 2.5, canvas.height / 1.8);

ctx.beginPath();
ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();

const avatar = await Canvas.loadImage(member.user.displayAvatarURL);
ctx.drawImage(avatar, 25, 25, 200, 200);

const attachment = new Discord.Attachment(canvas.toBuffer(), 'welcome-image.png');

channel.send(`Welcome to the server, ${member}!`, attachment);
});
---------------------------

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.