diff --git a/.gitignore b/.gitignore index c4e30ce5e8..b817169948 100644 --- a/.gitignore +++ b/.gitignore @@ -23,8 +23,6 @@ static/js/bundle.js static/third/gemoji/ static/third/zxcvbn/ static/locale/language_options.json -tools/setup/emoji_dump/bitmaps/ -tools/setup/emoji_dump/*.ttx tools/phantomjs node_modules npm-debug.log diff --git a/tools/setup/emoji_dump/emoji_dump.py b/tools/setup/emoji_dump/emoji_dump.py index e2e63ead09..fe98f28eab 100755 --- a/tools/setup/emoji_dump/emoji_dump.py +++ b/tools/setup/emoji_dump/emoji_dump.py @@ -11,15 +11,18 @@ from six import unichr from PIL import Image, ImageDraw, ImageFont +ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../') + +EMOJI_DUMP_DIR_PATH = os.path.join(ZULIP_PATH, 'var', 'emoji_dump') class MissingGlyphError(Exception): pass def color_font(code_point, code_point_to_fname_map): - in_name = 'bitmaps/strike0/{}.png'.format( + in_name = os.path.join(EMOJI_DUMP_DIR_PATH, 'bitmaps/strike0/{}.png'.format( code_point_to_fname_map[int(code_point, 16)] - ) + )) out_name = 'out/unicode/{}.png'.format(code_point) try: shutil.copyfile(in_name, out_name) @@ -70,10 +73,13 @@ def main(): # this is so we don't accidently leave ttx files from previous # runs of this script lying around - for fname in glob.glob("*ttx*"): + for fname in glob.glob(os.path.join(EMOJI_DUMP_DIR_PATH, "*ttx*")): os.remove(fname) - subprocess.call('ttx -v -z extfile NotoColorEmoji.ttf', shell=True) + # check if directory `var/emoji_dump` exists + subprocess.check_call(['mkdir', '-p', EMOJI_DUMP_DIR_PATH]) + + subprocess.call('ttx -v -z extfile -d {} NotoColorEmoji.ttf'.format(EMOJI_DUMP_DIR_PATH), shell=True) try: shutil.rmtree('out') @@ -90,7 +96,7 @@ def main(): emoji_map['red_car'] = emoji_map['oncoming_automobile'] failed = False - code_point_to_fname_map = code_point_to_file_name_map("NotoColorEmoji.ttx") + code_point_to_fname_map = code_point_to_file_name_map(os.path.join(EMOJI_DUMP_DIR_PATH, "NotoColorEmoji.ttx")) for name, code_point in emoji_map.items(): try: color_font(code_point, code_point_to_fname_map)