loonywizard / js-confetti

JS Confetti library that supports emojis 🦄 🎉 ⚡️
https://loonywizard.github.io/js-confetti/
MIT License
1.08k stars 45 forks source link

Feature Request - CSS / custom fonts #31

Closed ComedyTomedy closed 2 years ago

ComedyTomedy commented 2 years ago

I don't know much about canvas, but could it have a class & be targeted by CSS? That would allow the use of logo fonts like Font Awesome and open out the range of possible symbols hugely!

(Specifically, I want an explosion of batman logos - I haven't yet found the font, but I expect one exists!)

loonywizard commented 2 years ago

Hi, thanks for feature request!

Maybe I'm wrong, but it seems that we can't use CSS font-family and font-size for canvas. Instead, we need to use canvas context font property - look here in code https://github.com/loonywizard/js-confetti/blob/main/src/ConfettiShape.ts#L151

We can pass fontName prop to ConfettiShape, but I'm not sure if font-awesome works well with canvas. So I would recommend you to try to create "canvas+font-awesome" demo first

If that is what you need, you can open PR with your changes