| 14 | | var canvas = document.createElement( 'canvas' ), |
| 15 | | context = canvas.getContext && canvas.getContext( '2d' ), |
| 16 | | stringFromCharCode = String.fromCharCode, |
| 17 | | flag, flag2, tonedata, tone, tone2, technologist, technologist2; |
| | 21 | var stringFromCharCode = String.fromCharCode, |
| | 22 | flag, flag2, technologist, technologist2; |
| 66 | | case 'diversity': |
| 67 | | /* |
| 68 | | * This tests if the browser supports the Emoji Diversity specification, by rendering an |
| 69 | | * emoji with no skin tone specified (in this case, Santa). It then adds a skin tone, and |
| 70 | | * compares if the emoji rendering has changed. |
| 71 | | */ |
| 72 | | context.fillText( stringFromCharCode( 55356, 57221 ), 0, 0 ); |
| 73 | | tonedata = context.getImageData( 16, 16, 1, 1 ).data; |
| 74 | | tone = tonedata[0] + ',' + tonedata[1] + ',' + tonedata[2] + ',' + tonedata[3]; |
| 75 | | |
| 76 | | context.fillText( stringFromCharCode( 55356, 57221, 55356, 57343 ), 0, 0 ); |
| 77 | | // Chrome has issues comparing arrays, and Safari has issues converting arrays to strings. |
| 78 | | // So, we create our own string and compare that, instead. |
| 79 | | tonedata = context.getImageData( 16, 16, 1, 1 ).data; |
| 80 | | tone2 = tonedata[0] + ',' + tonedata[1] + ',' + tonedata[2] + ',' + tonedata[3]; |
| 81 | | |
| 82 | | return tone !== tone2; |
| 83 | | case 'simple': |
| 84 | | /* |
| 85 | | * This creates a smiling emoji, and checks to see if there is any image data in the |
| 86 | | * center pixel. In browsers that don't support emoji, the character will be rendered |
| 87 | | * as an empty square, so the center pixel will be blank. |
| 88 | | */ |
| 89 | | context.fillText( stringFromCharCode( 55357, 56835 ), 0, 0 ); |
| 90 | | return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0; |
| 91 | | case 'unicode8': |
| 92 | | /* |
| 93 | | * To check for Unicode 8 support, let's try rendering the most important advancement |
| 94 | | * that the Unicode Consortium have made in years: the burrito. |
| 95 | | */ |
| 96 | | context.fillText( stringFromCharCode( 55356, 57135 ), 0, 0 ); |
| 97 | | return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0; |
| 98 | | case 'unicode9': |
| 99 | | /* |
| 100 | | * Do Unicode 9 emoji render? |
| 101 | | * ¯\_(ツ)_/¯ |
| 102 | | */ |
| 103 | | context.fillText( stringFromCharCode( 55358, 56631 ), 0, 0 ); |
| 104 | | return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0; |