Skip to content

Commit

Permalink
add script that builds shortname-indexed json for each skin tone
Browse files Browse the repository at this point in the history
  • Loading branch information
intoeetive committed Jan 31, 2022
1 parent 169f450 commit af1f2d4
Show file tree
Hide file tree
Showing 7 changed files with 11,320 additions and 0 deletions.
40 changes: 40 additions & 0 deletions build/generate-reverse-map.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
// build the reverse mapping arrays for each skin variation

$emoji_data = json_decode(file_get_contents('https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji_pretty.json'), true);

$map = [];

$skin_tones = array(
'1F3FB' => 'skin-tone-2',
'1F3FC' => 'skin-tone-3',
'1F3FD' => 'skin-tone-4',
'1F3FE' => 'skin-tone-5',
'1F3FF' => 'skin-tone-6',
);

foreach($emoji_data as $emoji) {
foreach ($emoji['short_names'] as $short_name) {
$map['unified'][$short_name] = $emoji['unified'];
foreach($skin_tones as $code => $type) {
$map[$type][$short_name] = $emoji['unified'];
}

if(isset($emoji['skin_variations'])) {
foreach($emoji['skin_variations'] as $key => $var) {
if (isset($skin_tones[$key])) {
$type = $skin_tones[$key];
} else if (isset($skin_tones[$key . '-' . $key])) {
$type = $skin_tones[$key . '-' . $key];
} else {
continue;
}
$map[$type][$short_name] = $var['unified'];
}
}
}
}

foreach ($map as $type => $data) {
file_put_contents(dirname(__FILE__).'/../src/map-reverse-' . $type . '.json', json_encode($data, JSON_PRETTY_PRINT));
}
Loading

0 comments on commit af1f2d4

Please sign in to comment.