*/
function browserSupportsEmoji( type ) {
var canvas = document.createElement( 'canvas' ),
- context = canvas.getContext && canvas.getContext( '2d' );
+ context = canvas.getContext && canvas.getContext( '2d' ),
+ tone;
if ( ! context || ! context.fillText ) {
return false;
*/
context.fillText( String.fromCharCode( 55356, 56806, 55356, 56826 ), 0, 0 );
return canvas.toDataURL().length > 3000;
+ } else if ( 'diversity' === type ) {
+ /*
+ * This tests if the browser supports the Emoji Diversity specification, by rendering an
+ * emoji with no skin tone specified (in this case, Santa). It then adds a skin tone, and
+ * compares if the emoji rendering has changed.
+ */
+ context.fillText( String.fromCharCode( 55356, 57221 ), 0, 0 );
+ tone = context.getImageData( 16, 16, 1, 1 ).data.toString();
+ context.fillText( String.fromCharCode( 55356, 57221, 55356, 57343 ), 0, 0 );
+ // Chrome has issues comparing arrays, so we compare it as a string, instead.
+ return tone !== context.getImageData( 16, 16, 1, 1 ).data.toString();
} else {
if ( 'simple' === type ) {
/*
}
settings.supports = {
- simple: browserSupportsEmoji( 'simple' ),
- flag: browserSupportsEmoji( 'flag' ),
- unicode8: browserSupportsEmoji( 'unicode8' )
+ simple: browserSupportsEmoji( 'simple' ),
+ flag: browserSupportsEmoji( 'flag' ),
+ unicode8: browserSupportsEmoji( 'unicode8' ),
+ diversity: browserSupportsEmoji( 'diversity' )
};
settings.DOMReady = false;
settings.DOMReady = true;
};
- if ( ! settings.supports.simple || ! settings.supports.flag || ! settings.supports.unicode8 ) {
+ if ( ! settings.supports.simple || ! settings.supports.flag || ! settings.supports.unicode8 || ! settings.supports.diversity ) {
ready = function() {
settings.readyCallback();
};