TimboKZ / discord-spoiler-bot

🗣️🛑 Spoiler support for Discord
https://www.npmjs.com/package/discord-spoiler-bot
MIT License
61 stars 19 forks source link

Canvas.Font error on startup #1

Closed vegeta897 closed 7 years ago

vegeta897 commented 7 years ago

Using the example script, upon initializing this error comes up:

C:\d-bot\node_modules\discord-spoiler-bot\src\GifGenerator.js:28
const SOURCE_SANS_PRO = new Canvas.Font('SourceSansPro', path.join(FONT_PATH, 'SourceSansPro-Regular.ttf'));
                        ^
TypeError: Canvas.Font is not a constructor
TimboKZ commented 7 years ago

Hi, thanks for reporting this!

It seems node-canvas on Windows does not support TrueType fonts. I was developing on Linux so haven't noticed this before. I've fixed this issue in v1.0.2 (#2 ) by using a fallback on a standard font if Canvas.Font is not available. The font I'm currently using as a fallback doesn't look as good as Source Sans Pro and I will try to find a better looking one once I have a free moment.

vegeta897 commented 7 years ago

No rush from me, I've already applied a local workaround by just installing that font and skipping the font loading code.

Maybe you could add font face as a config property?

Edit: I just noticed your fix actually accomplishes the same thing as my workaround, so that's great.