diff --git a/third_party/color_emoji/add_glyphs.py b/third_party/color_emoji/add_glyphs.py index 77d5c7e89..7f7b4f8cd 100644 --- a/third_party/color_emoji/add_glyphs.py +++ b/third_party/color_emoji/add_glyphs.py @@ -85,9 +85,9 @@ EXTRA_SEQUENCES = { # Flag aliases - from: to FLAG_ALIASES = { 'BV': 'NO', - 'SJ': 'NO', - 'UM': 'FR', + 'CP': 'FR', 'HM': 'AU', + 'SJ': 'NO', 'UM': 'US', } diff --git a/third_party/color_emoji/emoji_builder.py b/third_party/color_emoji/emoji_builder.py index fa9f4115c..dd8ef3d11 100644 --- a/third_party/color_emoji/emoji_builder.py +++ b/third_party/color_emoji/emoji_builder.py @@ -353,6 +353,21 @@ class CBLC: self.pop_stream () +# copied from nototools/font_data +_UNICODE_CMAPS = {(4, 0, 3), (4, 3, 1), (12, 3, 10)} + +def delete_from_cmap(font, chars): + """Delete all characters in a list from the cmap tables of a font.""" + cmap_table = font['cmap'] + for table in cmap_table.tables: + table_tup = (table.format, table.platformID, table.platEncID) + if table_tup in _UNICODE_CMAPS: + for char in chars: + if char in table.cmap: + print 'removing %04x from %s' % (char, table_tup) + del table.cmap[char] + + def main (argv): import glob from fontTools import ttx, ttLib @@ -527,6 +542,11 @@ By default they are dropped. drop_outline_tables (font) print "Dropped outline ('glyf', 'CFF ') and related tables." + # hack removal of cmap pua entry for unknown flag glyph. If we try to + # remove it earlier, getGlyphID dies. Need to restructure all of this + # code. + delete_from_cmap(font, [0xfe82b]) + font.save (out_file) print "Output font '%s' generated." % out_file