mirror of https://github.com/zulip/zulip.git
build_emoji: Add `setup_old_emoji_farm()` function.
This commit adds `setup_old_emoji_farm()` function to the build_emoji script. This will change the way of setting up the old emoji farm. Earlier we used to extract the glyphs corresponding to each emoji from the `NotoColorEmoji.ttf` file. But since now we already have individual images in the new emoji farm(from iamcal's 'emoji-datasource-google' npm package) we can just symlink old emoji files to the new image files. This apart from helping us in cleaning up the `build_emoji` script will also help in reducing the increased size of the release tarball due to the addition of new emoji farm.
This commit is contained in:
parent
eed7d4b8d7
commit
273e37b2f9
|
@ -240,6 +240,54 @@ def setup_emoji_farm(cache_path, emoji_map, emoji_data):
|
|||
|
||||
generate_sprite_css_files(cache_path, emoji_map, emoji_data)
|
||||
|
||||
def setup_old_emoji_farm(cache_path, emoji_map):
|
||||
# type: (Text, Dict[Text, Text]) -> None
|
||||
# Code for setting up old emoji farm.
|
||||
# Some image files in the old emoji farm had a different name than in the new emoji
|
||||
# farm. `remapped_emojis` is a map that contains a mapping of their name in the old
|
||||
# emoji farm to their name in the new emoji farm.
|
||||
remapped_emojis = {
|
||||
"0023": "0023-20e3", # Hash
|
||||
"0030": "0030-20e3", # Zero
|
||||
"0031": "0031-20e3", # One
|
||||
"0032": "0032-20e3", # Two
|
||||
"0033": "0033-20e3", # Three
|
||||
"0034": "0034-20e3", # Four
|
||||
"0035": "0035-20e3", # Five
|
||||
"0036": "0036-20e3", # Six
|
||||
"0037": "0037-20e3", # Seven
|
||||
"0038": "0038-20e3", # Eight
|
||||
"0039": "0039-20e3", # Nine
|
||||
"1f48f": "1f469-200d-2764-200d-1f48b-200d-1f468", # Couple kiss
|
||||
"1f491": "1f469-200d-2764-200d-1f468", # Couple with heart
|
||||
}
|
||||
|
||||
os.chdir(cache_path)
|
||||
emoji_cache_path = os.path.join(cache_path, 'images', 'emoji')
|
||||
unicode_emoji_cache_path = os.path.join(cache_path, 'images', 'emoji', 'unicode')
|
||||
google_emoji_cache_path = os.path.join(cache_path, 'images-google-64')
|
||||
|
||||
# Symlink zulip.png image file.
|
||||
image_file_path = os.path.join(google_emoji_cache_path, 'zulip.png')
|
||||
symlink_path = os.path.join(emoji_cache_path, 'zulip.png')
|
||||
os.symlink(image_file_path, symlink_path)
|
||||
|
||||
unicode_symlink_path = os.path.join(unicode_emoji_cache_path, 'zulip.png')
|
||||
os.symlink(image_file_path, unicode_symlink_path)
|
||||
|
||||
for name, codepoint in emoji_map.items():
|
||||
mapped_codepoint = remapped_emojis.get(codepoint, codepoint)
|
||||
image_file_path = os.path.join(google_emoji_cache_path, '{}.png'.format(mapped_codepoint))
|
||||
symlink_path = os.path.join(emoji_cache_path, '{}.png'.format(name))
|
||||
os.symlink(image_file_path, symlink_path)
|
||||
try:
|
||||
# `emoji_map` contains duplicate entries for the same codepoint with different
|
||||
# names. So creation of symlink for <codepoint>.png may throw `FileExistsError`.
|
||||
unicode_symlink_path = os.path.join(unicode_emoji_cache_path, '{}.png'.format(codepoint))
|
||||
os.symlink(image_file_path, unicode_symlink_path)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
def dump_emojis(cache_path):
|
||||
# type: (str) -> None
|
||||
subprocess.call('ttx -v -z extfile -d {} NotoColorEmoji.ttf'.format(EMOJI_DUMP_DIR_PATH), shell=True)
|
||||
|
|
Loading…
Reference in New Issue