1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-12-27 21:15:19 +00:00

Have the preview script add VS16s to any assets that allow it. This fixes the preview of text-default emoji like the pawn and trademark symbol

This commit is contained in:
Nathan Downs 2018-06-27 10:55:27 -07:00
parent bc6a2c6a87
commit c0b9d0f803
3 changed files with 5718 additions and 5687 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,30 @@
var fs = require('fs');
var path = require('path');
var regex = new RegExp(fs.readFileSync(file('utils/regex')).toString(), 'g');
function fromCodePoint(codepoint) {
var code = typeof codepoint === 'string' ?
parseInt(codepoint, 16) : codepoint;
if (code < 0x10000) {
return String.fromCharCode(code);
}
code -= 0x10000;
return String.fromCharCode(
0xD800 + (code >> 10),
0xDC00 + (code & 0x3FF)
);
}
function countEmoji(emoji) {
var count = 0;
regex.lastIndex = 0;
while (regex.exec(emoji)) {
count++;
}
return count;
}
function file(which) {
return path.join(__dirname, '..', which);
}
@ -15,9 +39,16 @@ function file(which) {
fs.readdir(file('assets'), function (err, files) {
var page = fs.readFileSync(file('templates/preview.html')).toString().replace(
'{{emoji-list}}',
'<li>' + files.map(function (file) {
return file.replace('.ai', '').split('-').map(function (hex) {
return '&#x' + hex.toUpperCase() + ';';
'<li>' + files.map(function (filename) {
var codepoints = filename.replace('.ai', '').split('-');
var emoji = codepoints.map(function(codepoint) {
return fromCodePoint(codepoint);
}).join('');
if (countEmoji(emoji + '\ufe0f') === 1) {
codepoints.push('fe0f');
}
return codepoints.map(function (codepoint) {
return '&#x' + codepoint.toUpperCase() + ';';
}).join('');
}).join('</li>\n <li>')+ '</li>'
);