discord-canvas icon indicating copy to clipboard operation
discord-canvas copied to clipboard

when i try to make a welcome card

Open Ruben-Schadron opened this issue 1 year ago • 5 comments

(process:23100): Pango-WARNING **: 14:28:09.544: couldn't load font "The Bold Font Bold Not-Rotated 47px", falling back to "Sans Bold Not-Rotated 47px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.593: couldn't load font "The Bold Font Bold 47px", falling back to "Sans Bold 47px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.598: couldn't load font "The Bold Font Bold Not-Rotated 52px", falling back to "Sans Bold Not-Rotated 52px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.618: couldn't load font "The Bold Font Bold 52px", falling back to "Sans Bold 52px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.622: couldn't load font "The Bold Font Bold Not-Rotated 51px", falling back to "Sans Bold Not-Rotated 51px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.629: couldn't load font "The Bold Font Bold 51px", falling back to "Sans Bold 51px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.631: couldn't load font "The Bold Font Bold Not-Rotated 50px", falling back to "Sans Bold Not-Rotated 50px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.657: couldn't load font "The Bold Font Bold 50px", falling back to "Sans Bold 50px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.658: couldn't load font "The Bold Font Bold Not-Rotated 49px", falling back to "Sans Bold Not-Rotated 49px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.664: couldn't load font "The Bold Font Bold 49px", falling back to "Sans Bold 49px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.664: couldn't load font "The Bold Font Bold Not-Rotated 48px", falling back to "Sans Bold Not-Rotated 48px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.672: couldn't load font "The Bold Font Bold 48px", falling back to "Sans Bold 48px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.675: couldn't load font "The Bold Font Bold Not-Rotated 40px", falling back to "Sans Bold Not-Rotated 40px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.689: couldn't load font "The Bold Font Bold Not-Rotated 22px", falling back to "Sans Bold Not-Rotated 22px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.699: couldn't load font "Sketch Match Not-Rotated 75px", falling back to "Sans Not-Rotated 75px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.725: couldn't load font "The Bold Font Bold Not-Rotated 90px", falling back to "Sans Bold Not-Rotated 90px", expect ugly output.

Ruben-Schadron avatar Apr 10 '23 12:04 Ruben-Schadron

Could you provide an example of the part of the code that caused these errors please?

It looks like Canvas did not load the fonts before trying to generate your welcome image.

pioupia avatar Apr 11 '23 19:04 pioupia

const {Welcome} = require('discord-canvas')

const card = await new Welcome()
.setUsername("xixi52")
.setDiscriminator("0001")
.setMemberCount("140")
.setGuildName("Server DEV")
.setAvatar(`${member.avatarURL({dynamic: false})}`)
.setColor("border", "#8015EA")
.setColor("username-box", "#8015EA")
.setColor("discriminator-box", "#8015EA")
.setColor("message-box", "#8015EA")
.setColor("title", "#8015EA")
.setColor("avatar", "#8015EA")
.setBackground("https://www.freeiconspng.com/uploads/welcome-png-hd-17.png")
.toAttachment(); 
const attachment = new AttachmentBuilder(card.toBuffer(), "welcome-image.png");

Ruben-Schadron avatar Apr 17 '23 09:04 Ruben-Schadron

Personally, I don't have any font errors. There is only the background image that has to be downloaded directly from the site and then loaded locally, otherwise you get an error.

Perhaps your machine does not support font loading. Could you please say:

  1. Your version of Node.js
  2. Your version of the discord-canvas package
  3. If possible, your OS and its version.

If you are on Windows I've some idea to fix it (https://github.com/Automattic/node-canvas/issues/1608).

pioupia avatar Apr 17 '23 14:04 pioupia

nodejs version: v19.8.1 discord-canvas: 1.5.2 OS: Windows 11; 22H2

Ruben-Schadron avatar Apr 18 '23 08:04 Ruben-Schadron

~~I have the same problem. Have you found a solution?~~

Use this: npm i [email protected]

ghost avatar Jan 07 '24 19:01 ghost