From 0d36d125aaf5f9e43ff291cedafec806d1c0ddd7 Mon Sep 17 00:00:00 2001 From: Doug Felt Date: Tue, 7 Mar 2017 17:54:41 -0800 Subject: [PATCH] Fix display of 'parts' of sequences in the sequence column. When relying on aliasing, a number of single character emoji can be replaced by sequence emoji (in particular, gendered variants). If these images aren't present, the current code that displays a sequence 'visually' fails to find an image for one of the parts, so bails and there's no visual presentation for those sequences. To fix this, we first canonicalize the part we're looking for, and try to find an image for that, and if we fail we check for an alias and try to find an image for that. --- generate_emoji_html.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/generate_emoji_html.py b/generate_emoji_html.py index 4f3bad735..c6712c73b 100755 --- a/generate_emoji_html.py +++ b/generate_emoji_html.py @@ -87,16 +87,30 @@ def _generate_row_cells(key, font, aliases, dir_infos, basepaths, colors): return row_cells -def _get_desc(key_tuple, dir_infos, basepaths): +def _get_desc(key_tuple, aliases, dir_infos, basepaths): CELL_PREFIX = '' def _get_filepath(cp): + def get_key_filepath(key): + for i in range(len(dir_infos)): + info = dir_infos[i] + if key in info.filemap: + basepath = basepaths[i] + return path.join(basepath, info.filemap[key]) + return None + cp_key = tuple([cp]) - for i in range(len(dir_infos)): - info = dir_infos[i] - if cp_key in info.filemap: - basepath = basepaths[i] - return path.join(basepath, info.filemap[cp_key]) - return None + cp_key = unicode_data.get_canonical_emoji_sequence(cp_key) or cp_key + fp = get_key_filepath(cp_key) + if not fp: + if cp_key in aliases: + fp = get_key_filepath(aliases[cp_key]) + else: + print 'no alias for %s' % unicode_data.seq_to_string(cp_key) + if not fp: + print 'no part for %s in %s' % ( + unicode_data.seq_to_string(cp_key), + unicode_data.seq_to_string(key_tuple)) + return fp def _get_part(cp): if cp == 0x200d: # zwj, common so replace with '+' @@ -236,7 +250,7 @@ def _generate_content( for key in keys: row = _generate_row_cells(key, font, aliases, dir_infos, basepaths, colors) - row.append(_get_desc(key, dir_infos, basepaths)) + row.append(_get_desc(key, aliases, dir_infos, basepaths)) row.append(_get_name(key, annotations)) lines.append(''.join(row))