Skip to content

Instantly share code, notes, and snippets.

@leplay
Last active March 20, 2019 13:43
Show Gist options
  • Save leplay/3b5c8ff058d8cb584f8e3ae12f31bf24 to your computer and use it in GitHub Desktop.
Save leplay/3b5c8ff058d8cb584f8e3ae12f31bf24 to your computer and use it in GitHub Desktop.
Detects support for emoji character sets.
// https://stackoverflow.com/questions/45576748/how-can-i-detect-rendering-support-for-emoji-in-javascript
// https://raw.githubusercontent.com/Modernizr/Modernizr/master/feature-detects/emoji.js
// function check (emoji) {
// var pixelRatio = window.devicePixelRatio || 1;
// var offset = 12 * pixelRatio;
// var node = document.createElement('canvas');
// var ctx = node.getContext('2d');
// ctx.fillStyle = '#f00';
// ctx.textBaseline = 'top';
// ctx.font = '32px Arial';
// ctx.fillText(emoji, 0, 0); // U+1F428 KOALA
// console.log(ctx.getImageData(offset, offset, 1, 1).data[0] !== 0)
// return ctx.getImageData(offset, offset, 1, 1).data[0] !== 0
// }
check('😁')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment