Created
December 10, 2013 03:24
-
-
Save mathisonian/7885295 to your computer and use it in GitHub Desktop.
Detect emoji support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine if this browser supports emoji. | |
* | |
* Modified from https://gist.github.com/mwunsch/4710561 | |
* and probobly originally github's javascript source | |
*/ | |
function doesSupportEmoji() { | |
var context, smiley; | |
if (!document.createElement('canvas').getContext) return; | |
context = document.createElement('canvas').getContext('2d'); | |
if (typeof context.fillText != 'function') return; | |
smile = String.fromCharCode(55357) + String.fromCharCode(56835); | |
context.textBaseline = "top"; | |
context.font = "32px Arial"; | |
context.fillText(smile, 0, 0); | |
return context.getImageData(16, 16, 1, 1).data[0] !== 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var context, smiley;
should bevar context, smile;