From b5c7e8035ccc271ad786178f6b209fa2065dca05 Mon Sep 17 00:00:00 2001 From: Doug Felt Date: Wed, 1 Feb 2017 12:35:34 -0800 Subject: [PATCH 1/5] Use waving black flag for subregion flag sequences. This was a recent change from the UTC. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7f6835769..2b0b35023 100644 --- a/Makefile +++ b/Makefile @@ -160,7 +160,7 @@ $(RESIZED_FLAGS_DIR)/%.png: $(FLAGS_DIR)/%.png | $(RESIZED_FLAGS_DIR) @convert -extent 136x128 -gravity center -background none "$<" "$@" flag-symlinks: $(RESIZED_FLAG_FILES) | $(RENAMED_FLAGS_DIR) - @$(subst ^, , \ + $(subst ^, , \ $(join \ $(FLAGS:%=ln^-fs^../resized_flags/%.png^), \ $(RENAMED_FLAG_FILES:%=%; ) \ From d270ecad996738be6f02069612cf7de665940969 Mon Sep 17 00:00:00 2001 From: Doug Felt Date: Fri, 3 Feb 2017 13:12:08 -0800 Subject: [PATCH 2/5] Generate unknown flag for unrecognized subregion emoji sequences. Instead of writing code to build the additional lookups needed for subregion missing flag handling, this adds a GSUB table to the template and lets add_glyphs do its normal thing to the first GSUB lookup. --- Makefile | 2 +- NotoColorEmoji.tmpl.ttx.tmpl | 316 ++++++++++++++++++++++++++ third_party/color_emoji/add_glyphs.py | 11 +- 3 files changed, 327 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2b0b35023..119383cc4 100644 --- a/Makefile +++ b/Makefile @@ -213,7 +213,7 @@ clean: rm -rf $(BUILD_DIR) .SECONDARY: $(EMOJI_FILES) $(FLAG_FILES) $(RESIZED_FLAG_FILES) $(RENAMED_FLAG_FILES) \ - $(ALL_QUANTIZED_FILES) $(ALL_COMPRESSED_FILES) + $(ALL_QUANTIZED_FILES) $(ALL_COMPRESSED_FILES) NotoColorEmoji.tmpl.ttx .PHONY: clean flags emoji renamed_flags quantized compressed check_compress_tool diff --git a/NotoColorEmoji.tmpl.ttx.tmpl b/NotoColorEmoji.tmpl.ttx.tmpl index e63c871d3..b4585df19 100644 --- a/NotoColorEmoji.tmpl.ttx.tmpl +++ b/NotoColorEmoji.tmpl.ttx.tmpl @@ -8,6 +8,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -127,6 +166,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -136,6 +214,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -199,4 +316,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/third_party/color_emoji/add_glyphs.py b/third_party/color_emoji/add_glyphs.py index c5bf6919e..f5f29080c 100644 --- a/third_party/color_emoji/add_glyphs.py +++ b/third_party/color_emoji/add_glyphs.py @@ -59,9 +59,18 @@ def add_ligature (font, seq, name): font['GSUB'] = add_emoji_gsub.create_simple_gsub([lookup]) else: lookup = font['GSUB'].table.LookupList.Lookup[0] - assert lookup.LookupType == 4 + # assert lookup.LookupType == 4 assert lookup.LookupFlag == 0 + # importXML doesn't fully init GSUB structures, so help it out + if not hasattr(lookup, 'LookupType'): + st = lookup.SubTable[0] + assert st.LookupType == 4 + setattr(lookup, 'LookupType', 4) + + if not hasattr(st, 'ligatures'): + setattr(st, 'ligatures', {}) + ligatures = lookup.SubTable[0].ligatures lig = otTables.Ligature() From 58097d9d4c1681ad29a3bbd77b21eb9c7e48466d Mon Sep 17 00:00:00 2001 From: Doug Felt Date: Fri, 10 Feb 2017 10:23:02 -0800 Subject: [PATCH 3/5] Generate reversed GSUB sequences for subregion flags too. Since subregion flag sequences consist of BN and ON they can be impacted by bidi, and once again we have the problem that these are processed in visual order so we need GSUB rules such that we can handle them in either direction. All subregion flag sequences contain U+E007F, so we use that as a trigger for adding the reversed sequence. We also need to handle emitting the missing flag glyph for the reversed sequences. And we also want to strip out tag glyphs when the context is reversed. This means the chaining context should include 'E007F' as well. --- NotoColorEmoji.tmpl.ttx.tmpl | 4 ++++ third_party/color_emoji/add_glyphs.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NotoColorEmoji.tmpl.ttx.tmpl b/NotoColorEmoji.tmpl.ttx.tmpl index b4585df19..6811f5c34 100644 --- a/NotoColorEmoji.tmpl.ttx.tmpl +++ b/NotoColorEmoji.tmpl.ttx.tmpl @@ -443,6 +443,7 @@ + @@ -510,6 +511,9 @@ + + + diff --git a/third_party/color_emoji/add_glyphs.py b/third_party/color_emoji/add_glyphs.py index f5f29080c..aba1facf8 100644 --- a/third_party/color_emoji/add_glyphs.py +++ b/third_party/color_emoji/add_glyphs.py @@ -178,7 +178,7 @@ def add_lig_sequence(ligatures, seq, n): print 'lig sequence %s, replace %s with %s' % ( tseq, ligatures[tseq], n) ligatures[tseq] = n - if 'u200D' in seq: + if 'u200D' in seq or 'uE007F' in seq: rev_seq = seq[:] rev_seq.reverse() for i in xrange(1, len(rev_seq)): From a62c0be851e01a637b7996c5805d0f0a97a4dc5f Mon Sep 17 00:00:00 2001 From: Doug Felt Date: Fri, 10 Feb 2017 17:57:24 -0800 Subject: [PATCH 4/5] Add GSUB substitutions to provide unknown flag for pairs of RIS. A current issue in Harfbuzz requires that you not perform a delete on index 1 before running a lookup on index 0. --- Makefile | 4 +- NotoColorEmoji.tmpl.ttx.tmpl | 239 ++++++++++++++++++++++++-- third_party/color_emoji/add_glyphs.py | 19 +- 3 files changed, 235 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 119383cc4..7f6835769 100644 --- a/Makefile +++ b/Makefile @@ -160,7 +160,7 @@ $(RESIZED_FLAGS_DIR)/%.png: $(FLAGS_DIR)/%.png | $(RESIZED_FLAGS_DIR) @convert -extent 136x128 -gravity center -background none "$<" "$@" flag-symlinks: $(RESIZED_FLAG_FILES) | $(RENAMED_FLAGS_DIR) - $(subst ^, , \ + @$(subst ^, , \ $(join \ $(FLAGS:%=ln^-fs^../resized_flags/%.png^), \ $(RENAMED_FLAG_FILES:%=%; ) \ @@ -213,7 +213,7 @@ clean: rm -rf $(BUILD_DIR) .SECONDARY: $(EMOJI_FILES) $(FLAG_FILES) $(RESIZED_FLAG_FILES) $(RENAMED_FLAG_FILES) \ - $(ALL_QUANTIZED_FILES) $(ALL_COMPRESSED_FILES) NotoColorEmoji.tmpl.ttx + $(ALL_QUANTIZED_FILES) $(ALL_COMPRESSED_FILES) .PHONY: clean flags emoji renamed_flags quantized compressed check_compress_tool diff --git a/NotoColorEmoji.tmpl.ttx.tmpl b/NotoColorEmoji.tmpl.ttx.tmpl index 6811f5c34..a2ae62b7e 100644 --- a/NotoColorEmoji.tmpl.ttx.tmpl +++ b/NotoColorEmoji.tmpl.ttx.tmpl @@ -1,5 +1,5 @@ - + @@ -47,6 +47,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -71,7 +97,7 @@ - + @@ -93,7 +119,7 @@ - + @@ -144,8 +170,8 @@ - - + + @@ -157,7 +183,7 @@ - + @@ -205,6 +231,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -253,6 +305,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -337,18 +415,18 @@ - + + - + - @@ -359,6 +437,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -399,7 +503,6 @@ - @@ -495,7 +598,7 @@ - + @@ -507,6 +610,7 @@ + @@ -516,6 +620,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/third_party/color_emoji/add_glyphs.py b/third_party/color_emoji/add_glyphs.py index aba1facf8..5ab52f35c 100644 --- a/third_party/color_emoji/add_glyphs.py +++ b/third_party/color_emoji/add_glyphs.py @@ -160,7 +160,7 @@ glyph_names = set() ligatures = {} def add_lig_sequence(ligatures, seq, n): - # We have emoji sequences using regional indicator symbols, + # We have emoji sequences using regional indicator symbols, tags, # ZWJ, fitzpatrick modifiers, and combinations of ZWJ and fitzpatrick # modifiers. Currently, Harfbuzz special-cases the fitzpatrick # modifiers to treat them as combining marks instead of as Other @@ -169,10 +169,10 @@ def add_lig_sequence(ligatures, seq, n): # emoji sequences in an RTL context we need GSUB sequences that match # this order. # Regional indicator symbols are LTR, and emoji+fitzpatrick are - # effectively LTR, so we only reorder sequences with ZWJ. If however - # the ZWJ sequence has fitzpatrick modifiers, those need to still follow - # the emoji they logically follow, so simply reversing the sequence - # doesn't work. This code assumes the lig sequence is valid. + # effectively LTR, so we only reorder sequences with ZWJ or tags. If + # however the ZWJ sequence has fitzpatrick modifiers, those need to + # still follow the emoji they logically follow, so simply reversing the + # sequence doesn't work. This code assumes the lig sequence is valid. tseq = tuple(seq) if tseq in ligatures: print 'lig sequence %s, replace %s with %s' % ( @@ -261,15 +261,6 @@ if have_flags: name = _reg_lig_name(flag_to) add_lig_sequence(ligatures, seq, name) - print 'Adding unused flag sequences' - # every flag sequence we don't have gets the missing flag glyph - for first in regional_names: - for second in regional_names: - seq = (first, second) - if seq not in ligatures: - add_lig_sequence(ligatures, seq, UNKNOWN_FLAG_GLYPH_NAME) - - keyed_ligatures = collections.defaultdict(list) for k, v in ligatures.iteritems(): first = k[0] From e5146fcecb6382a59e6e5a1127d98683d8797f0f Mon Sep 17 00:00:00 2001 From: Doug Felt Date: Thu, 16 Feb 2017 15:07:47 -0800 Subject: [PATCH 5/5] Avoid duplicate names in glyphorder table. When adding a single glyph that was not in the cmap, this was adding the name for that glyph twice. --- third_party/color_emoji/add_glyphs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/third_party/color_emoji/add_glyphs.py b/third_party/color_emoji/add_glyphs.py index 5ab52f35c..2bbf41f5a 100644 --- a/third_party/color_emoji/add_glyphs.py +++ b/third_party/color_emoji/add_glyphs.py @@ -204,7 +204,8 @@ for (u, filename) in img_pairs: cp = ord(char) if cp not in c and not is_vs(cp): name = glyph_name (char) - g.append(name) + if name not in glyph_names: + g.append(name) c[cp] = name if len (u) > 1: h[name] = [0, 0]