wp/wp-includes/js/wp-emoji-loader.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    67 		context.font = '600 32px Arial';
    67 		context.font = '600 32px Arial';
    68 
    68 
    69 		switch ( type ) {
    69 		switch ( type ) {
    70 			case 'flag':
    70 			case 'flag':
    71 				/*
    71 				/*
    72 				 * Test for UN flag compatibility. This is the least supported of the letter locale flags,
    72 				 * Test for Transgender flag compatibility. This flag is shortlisted for the Emoji 13 spec,
    73 				 * so gives us an easy test for full support.
    73 				 * but has landed in Twemoji early, so we can add support for it, too.
    74 				 *
    74 				 *
    75 				 * To test for support, we try to render it, and compare the rendering to how it would look if
    75 				 * To test for support, we try to render it, and compare the rendering to how it would look if
    76 				 * the browser doesn't render it correctly ([U] + [N]).
    76 				 * the browser doesn't render it correctly (white flag emoji + transgender symbol).
    77 				 */
    77 				 */
    78 				isIdentical = emojiSetsRenderIdentically(
    78 				isIdentical = emojiSetsRenderIdentically(
    79 					[ 0xD83C, 0xDDFA, 0xD83C, 0xDDF3 ],
    79 					[ 0x1F3F3, 0xFE0F, 0x200D, 0x26A7, 0xFE0F ],
    80 					[ 0xD83C, 0xDDFA, 0x200B, 0xD83C, 0xDDF3 ]
    80 					[ 0x1F3F3, 0xFE0F, 0x200B, 0x26A7, 0xFE0F ]
    81 				);
    81 				);
    82 
    82 
    83 				if ( isIdentical ) {
    83 				if ( isIdentical ) {
    84 					return false;
    84 					return false;
    85 				}
    85 				}
    86 
    86 
    87 				/*
    87 				/*
       
    88 				 * Test for UN flag compatibility. This is the least supported of the letter locale flags,
       
    89 				 * so gives us an easy test for full support.
       
    90 				 *
       
    91 				 * To test for support, we try to render it, and compare the rendering to how it would look if
       
    92 				 * the browser doesn't render it correctly ([U] + [N]).
       
    93 				 */
       
    94 				isIdentical = emojiSetsRenderIdentically(
       
    95 					[ 0xD83C, 0xDDFA, 0xD83C, 0xDDF3 ],
       
    96 					[ 0xD83C, 0xDDFA, 0x200B, 0xD83C, 0xDDF3 ]
       
    97 				);
       
    98 
       
    99 				if ( isIdentical ) {
       
   100 					return false;
       
   101 				}
       
   102 
       
   103 				/*
    88 				 * Test for English flag compatibility. England is a country in the United Kingdom, it
   104 				 * Test for English flag compatibility. England is a country in the United Kingdom, it
    89 				 * does not have a two letter locale code but rather an five letter sub-division code.
   105 				 * does not have a two letter locale code but rather an five letter sub-division code.
    90 				 *
   106 				 *
    91 				 * To test for support, we try to render it, and compare the rendering to how it would look if
   107 				 * To test for support, we try to render it, and compare the rendering to how it would look if
    92 				 * the browser doesn't render it correctly (black flag emoji + [G] + [B] + [E] + [N] + [G]).
   108 				 * the browser doesn't render it correctly (black flag emoji + [G] + [B] + [E] + [N] + [G]).
    97 				);
   113 				);
    98 
   114 
    99 				return ! isIdentical;
   115 				return ! isIdentical;
   100 			case 'emoji':
   116 			case 'emoji':
   101 				/*
   117 				/*
   102 				 * Love is love.
   118 				 * So easy, even a baby could do it!
   103 				 *
   119 				 *
   104 				 * To test for Emoji 12 support, try to render a new emoji: men holding hands, with different skin
   120 				 *  To test for Emoji 13 support, try to render a new emoji: Man Feeding Baby.
   105 				 * tone modifiers.
   121 				 *
       
   122 				 * The Man Feeding Baby emoji is a ZWJ sequence combining 👨 Man, a Zero Width Joiner and 🍼 Baby Bottle.
       
   123 				 *
       
   124 				 * 0xD83D, 0xDC68 == Man emoji.
       
   125 				 * 0x200D == Zero-Width Joiner (ZWJ) that links the two code points for the new emoji or
       
   126 				 * 0x200B == Zero-Width Space (ZWS) that is rendered for clients not supporting the new emoji.
       
   127 				 * 0xD83C, 0xDF7C == Baby Bottle.
   106 				 *
   128 				 *
   107 				 * When updating this test for future Emoji releases, ensure that individual emoji that make up the
   129 				 * When updating this test for future Emoji releases, ensure that individual emoji that make up the
   108 				 * sequence come from older emoji standards.
   130 				 * sequence come from older emoji standards.
   109 				 */
   131 				 */
   110 				isIdentical = emojiSetsRenderIdentically(
   132 				isIdentical = emojiSetsRenderIdentically(
   111 					[0xD83D, 0xDC68, 0xD83C, 0xDFFE, 0x200D, 0xD83E, 0xDD1D, 0x200D, 0xD83D, 0xDC68, 0xD83C, 0xDFFC],
   133 					[0xD83D, 0xDC68, 0x200D, 0xD83C, 0xDF7C],
   112 					[0xD83D, 0xDC68, 0xD83C, 0xDFFE, 0x200B, 0xD83E, 0xDD1D, 0x200B, 0xD83D, 0xDC68, 0xD83C, 0xDFFC]
   134 					[0xD83D, 0xDC68, 0x200B, 0xD83C, 0xDF7C]
   113 				);
   135 				);
   114 
   136 
   115 				return ! isIdentical;
   137 				return ! isIdentical;
   116 		}
   138 		}
   117 
   139