Skip to content

Commit

Permalink
tools/setup/emoji_dump/emoji_dump.py: Move bitmaps & *.ttx to var/.
Browse files Browse the repository at this point in the history
Also update .gitignore to remove the old .gitignore markings for
these files' old locations.
  • Loading branch information
taranjeet authored and timabbott committed Aug 2, 2016
1 parent 4c592bd commit b82836a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions tools/setup/emoji_dump/emoji_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@

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)
Expand Down Expand Up @@ -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')
Expand All @@ -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)
Expand Down

0 comments on commit b82836a

Please sign in to comment.