How can I detect rendering support for emoji in Ja

2019-04-08 21:32发布

I want to add emoji to my site, but hide them if they're not supported on the platform, rather than showing little squares.

I have a feeling that this isn't possible, but does anybody disagree? How can this be done?

C

2条回答
戒情不戒烟
2楼-- · 2019-04-08 22:16

In case if someone is looking for a library, then here is the one if-emoji. It uses the same approach Roko has used in his answer.

查看更多
祖国的老花朵
3楼-- · 2019-04-08 22:31

Try to paint a font (in the Emoji range) to canvas and read a pixel using getImageData. If the pixel's Alpha channel data[3] you're interested-in is not transparent (like for example in the center of ￿) than might be an Emoji

查看更多
登录 后发表回答