Changeset 55241
- Timestamp:
- 02/06/2023 09:35:25 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/lib/emoji-loader.js
r53150 r55241 17 17 * @private 18 18 * 19 * @param { number[]} set1 Set of Emoji character codes.20 * @param { number[]} set2 Set of Emoji character codes.19 * @param {string} set1 Set of Emoji to test. 20 * @param {string} set2 Set of Emoji to test. 21 21 * 22 22 * @return {boolean} True if the two sets render the same. 23 23 */ 24 24 function emojiSetsRenderIdentically( set1, set2 ) { 25 var stringFromCharCode = String.fromCharCode;26 27 25 // Cleanup from previous test. 28 26 context.clearRect( 0, 0, canvas.width, canvas.height ); 29 context.fillText( s tringFromCharCode.apply( this, set1 ), 0, 0 );27 context.fillText( set1, 0, 0 ); 30 28 var rendered1 = canvas.toDataURL(); 31 29 32 30 // Cleanup from previous test. 33 31 context.clearRect( 0, 0, canvas.width, canvas.height ); 34 context.fillText( s tringFromCharCode.apply( this, set2 ), 0, 0 );32 context.fillText( set2, 0, 0 ); 35 33 var rendered2 = canvas.toDataURL(); 36 34 … … 39 37 40 38 /** 41 * Detects if the browser supports rendering emoji or flag emoji. 42 * 43 * Flag emoji are a single glyph made of two characters, so some browsers 44 * (notably, Firefox OS X) don't support them. 39 * Determines if the browser properly renders Emoji that Twemoji can supplement. 45 40 * 46 41 * @since 4.2.0 … … 70 65 case 'flag': 71 66 /* 72 * Test for Transgender flag compatibility. This flag is shortlisted for the Emoji 13 spec, 73 * but has landed in Twemoji early, so we can add support for it, too. 67 * Test for Transgender flag compatibility. Added in Unicode 13. 74 68 * 75 69 * To test for support, we try to render it, and compare the rendering to how it would look if … … 77 71 */ 78 72 isIdentical = emojiSetsRenderIdentically( 79 [ 0x1F3F3, 0xFE0F, 0x200D, 0x26A7, 0xFE0F ],80 [ 0x1F3F3, 0xFE0F, 0x200B, 0x26A7, 0xFE0F ]73 '\uD83C\uDFF3\uFE0F\u200D\u26A7\uFE0F', // as a zero-width joiner sequence 74 '\uD83C\uDFF3\uFE0F\u200B\u26A7\uFE0F' // separated by a zero-width space 81 75 ); 82 76 … … 93 87 */ 94 88 isIdentical = emojiSetsRenderIdentically( 95 [ 0xD83C, 0xDDFA, 0xD83C, 0xDDF3 ],96 [ 0xD83C, 0xDDFA, 0x200B, 0xD83C, 0xDDF3 ]89 '\uD83C\uDDFA\uD83C\uDDF3', // as the sequence of two code points 90 '\uD83C\uDDFA\u200B\uD83C\uDDF3' // as the two code points separated by a zero-width space 97 91 ); 98 92 … … 103 97 /* 104 98 * Test for English flag compatibility. England is a country in the United Kingdom, it 105 * does not have a two letter locale code but rather a nfive letter sub-division code.99 * does not have a two letter locale code but rather a five letter sub-division code. 106 100 * 107 101 * To test for support, we try to render it, and compare the rendering to how it would look if … … 109 103 */ 110 104 isIdentical = emojiSetsRenderIdentically( 111 [ 0xD83C, 0xDFF4, 0xDB40, 0xDC67, 0xDB40, 0xDC62, 0xDB40, 0xDC65, 0xDB40, 0xDC6E, 0xDB40, 0xDC67, 0xDB40, 0xDC7F ], 112 [ 0xD83C, 0xDFF4, 0x200B, 0xDB40, 0xDC67, 0x200B, 0xDB40, 0xDC62, 0x200B, 0xDB40, 0xDC65, 0x200B, 0xDB40, 0xDC6E, 0x200B, 0xDB40, 0xDC67, 0x200B, 0xDB40, 0xDC7F ] 105 // as the flag sequence 106 '\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67\uDB40\uDC7F', 107 // with each code point separated by a zero-width space 108 '\uD83C\uDFF4\u200B\uDB40\uDC67\u200B\uDB40\uDC62\u200B\uDB40\uDC65\u200B\uDB40\uDC6E\u200B\uDB40\uDC67\u200B\uDB40\uDC7F' 113 109 ); 114 110 … … 134 130 */ 135 131 isIdentical = emojiSetsRenderIdentically( 136 [0x1FAF1, 0x1F3FB, 0x200D, 0x1FAF2, 0x1F3FF],137 [0x1FAF1, 0x1F3FB, 0x200B, 0x1FAF2, 0x1F3FF]132 '\uD83E\uDEF1\uD83C\uDFFB\u200D\uD83E\uDEF2\uD83C\uDFFF', // as the zero-width joiner sequence 133 '\uD83E\uDEF1\uD83C\uDFFB\u200B\uD83E\uDEF2\uD83C\uDFFF' // separated by a zero-width space 138 134 ); 139 135
Note: See TracChangeset
for help on using the changeset viewer.