How can I detect rendering support for emoji in Ja

2019-04-08 22:18发布

问题:

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

回答1:

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