tools/setup/emoji_dump/emoji_dump.py: Move bitmaps & *.ttx to var/.

Also update .gitignore to remove the old .gitignore markings for
these files' old locations.
This commit is contained in:
Taranjeet Singh 2016-07-31 14:33:58 +05:30 committed by Tim Abbott
parent 4c592bd8d4
commit b82836a901
2 changed files with 11 additions and 7 deletions

2
.gitignore vendored
View File

@ -23,8 +23,6 @@ static/js/bundle.js
static/third/gemoji/ static/third/gemoji/
static/third/zxcvbn/ static/third/zxcvbn/
static/locale/language_options.json static/locale/language_options.json
tools/setup/emoji_dump/bitmaps/
tools/setup/emoji_dump/*.ttx
tools/phantomjs tools/phantomjs
node_modules node_modules
npm-debug.log npm-debug.log

View File

@ -11,15 +11,18 @@ from six import unichr
from PIL import Image, ImageDraw, ImageFont 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): class MissingGlyphError(Exception):
pass pass
def color_font(code_point, code_point_to_fname_map): 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)] code_point_to_fname_map[int(code_point, 16)]
) ))
out_name = '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)
@ -70,10 +73,13 @@ def main():
# this is so we don't accidently leave ttx files from previous # this is so we don't accidently leave ttx files from previous
# runs of this script lying around # 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) 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: try:
shutil.rmtree('out') shutil.rmtree('out')
@ -90,7 +96,7 @@ def main():
emoji_map['red_car'] = emoji_map['oncoming_automobile'] emoji_map['red_car'] = emoji_map['oncoming_automobile']
failed = False 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(): 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)