emoji_dump: Fix buggy path management.

In d583710f7c, I apparently broke the
color emoji handling, which was masked (for test purposes) by the fact
that we catch an expection if color doesn't work and in that case fall
back to black and white emoji.
This commit is contained in:
Tim Abbott 2016-09-08 14:54:44 -07:00
parent a6fffe5120
commit aca6636729
2 changed files with 11 additions and 10 deletions

View File

@ -5,5 +5,5 @@ set -x
rm -rf static/third/gemoji/images rm -rf static/third/gemoji/images
(cd tools/setup/emoji_dump && python ./emoji_dump.py) (cd tools/setup/emoji_dump && python ./emoji_dump.py)
mkdir -p static/third/gemoji/images mkdir -p static/third/gemoji/images
mv tools/setup/emoji_dump/out static/third/gemoji/images/emoji mv var/emoji_dump/out static/third/gemoji/images/emoji
cp -RPp static/assets/zulip-emoji/* static/third/gemoji/images/emoji/ cp -RPp static/assets/zulip-emoji/* static/third/gemoji/images/emoji/

View File

@ -27,8 +27,8 @@ class MissingGlyphError(Exception):
def color_font(code_point, code_point_to_fname_map): def color_font(code_point, code_point_to_fname_map):
name = code_point_to_fname_map[int(code_point, 16)] name = code_point_to_fname_map[int(code_point, 16)]
in_name = EMOJI_DUMP_PATH('bitmaps/strike0/{}.png'.format(name)) in_name = 'bitmaps/strike0/{}.png'.format(name)
out_name = EMOJI_DUMP_PATH('out/unicode/{}.png'.format(code_point)) out_name = 'out/unicode/{}.png'.format(code_point)
try: try:
shutil.copyfile(in_name, out_name) shutil.copyfile(in_name, out_name)
@ -83,6 +83,14 @@ def main():
subprocess.call('ttx -v -z extfile -d {} NotoColorEmoji.ttf'.format(EMOJI_DUMP_DIR_PATH), shell=True) subprocess.call('ttx -v -z extfile -d {} NotoColorEmoji.ttf'.format(EMOJI_DUMP_DIR_PATH), shell=True)
emoji_map = json.load(open('emoji_map.json'))
# Fix data problem with red/blue cars being inaccurate.
emoji_map['blue_car'] = emoji_map['red_car']
emoji_map['red_car'] = emoji_map['oncoming_automobile']
code_point_to_fname_map = code_point_to_file_name_map(EMOJI_DUMP_PATH("NotoColorEmoji.ttx"))
os.chdir(EMOJI_DUMP_DIR_PATH)
try: try:
shutil.rmtree('out') shutil.rmtree('out')
except OSError: except OSError:
@ -91,14 +99,7 @@ def main():
os.mkdir('out') os.mkdir('out')
os.mkdir('out/unicode') os.mkdir('out/unicode')
emoji_map = json.load(open('emoji_map.json'))
# Fix data problem with red/blue cars being inaccurate.
emoji_map['blue_car'] = emoji_map['red_car']
emoji_map['red_car'] = emoji_map['oncoming_automobile']
failed = False failed = False
code_point_to_fname_map = code_point_to_file_name_map(EMOJI_DUMP_PATH("NotoColorEmoji.ttx"))
for name, code_point in emoji_map.items(): for name, code_point in emoji_map.items():
try: try:
color_font(code_point, code_point_to_fname_map) color_font(code_point, code_point_to_fname_map)