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.
This commit is contained in:
Doug Felt 2017-02-10 17:57:24 -08:00
parent 58097d9d4c
commit a62c0be851
3 changed files with 235 additions and 27 deletions

View file

@ -160,7 +160,7 @@ $(RESIZED_FLAGS_DIR)/%.png: $(FLAGS_DIR)/%.png | $(RESIZED_FLAGS_DIR)
@convert -extent 136x128 -gravity center -background none "$<" "$@" @convert -extent 136x128 -gravity center -background none "$<" "$@"
flag-symlinks: $(RESIZED_FLAG_FILES) | $(RENAMED_FLAGS_DIR) flag-symlinks: $(RESIZED_FLAG_FILES) | $(RENAMED_FLAGS_DIR)
$(subst ^, , \ @$(subst ^, , \
$(join \ $(join \
$(FLAGS:%=ln^-fs^../resized_flags/%.png^), \ $(FLAGS:%=ln^-fs^../resized_flags/%.png^), \
$(RENAMED_FLAG_FILES:%=%; ) \ $(RENAMED_FLAG_FILES:%=%; ) \
@ -213,7 +213,7 @@ clean:
rm -rf $(BUILD_DIR) rm -rf $(BUILD_DIR)
.SECONDARY: $(EMOJI_FILES) $(FLAG_FILES) $(RESIZED_FLAG_FILES) $(RENAMED_FLAG_FILES) \ .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 .PHONY: clean flags emoji renamed_flags quantized compressed check_compress_tool

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="2.3"> <ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.6">
<GlyphOrder> <GlyphOrder>
<!-- The 'id' attribute is only for humans; it is ignored when parsed. --> <!-- The 'id' attribute is only for humans; it is ignored when parsed. -->
@ -47,6 +47,32 @@
<GlyphID id="41" name="uE007F"/> <GlyphID id="41" name="uE007F"/>
<GlyphID id="42" name="u1F3F4"/> <GlyphID id="42" name="u1F3F4"/>
<GlyphID id="43" name="uFE82B"/> <GlyphID id="43" name="uFE82B"/>
<GlyphID id="44" name="u1F1E6"/>
<GlyphID id="45" name="u1F1E7"/>
<GlyphID id="46" name="u1F1E8"/>
<GlyphID id="47" name="u1F1E9"/>
<GlyphID id="48" name="u1F1EA"/>
<GlyphID id="49" name="u1F1EB"/>
<GlyphID id="50" name="u1F1EC"/>
<GlyphID id="51" name="u1F1ED"/>
<GlyphID id="52" name="u1F1EE"/>
<GlyphID id="53" name="u1F1EF"/>
<GlyphID id="54" name="u1F1F0"/>
<GlyphID id="55" name="u1F1F1"/>
<GlyphID id="56" name="u1F1F2"/>
<GlyphID id="57" name="u1F1F3"/>
<GlyphID id="58" name="u1F1F4"/>
<GlyphID id="59" name="u1F1F5"/>
<GlyphID id="60" name="u1F1F6"/>
<GlyphID id="61" name="u1F1F7"/>
<GlyphID id="62" name="u1F1F8"/>
<GlyphID id="63" name="u1F1F9"/>
<GlyphID id="64" name="u1F1FA"/>
<GlyphID id="65" name="u1F1FB"/>
<GlyphID id="66" name="u1F1FC"/>
<GlyphID id="67" name="u1F1FD"/>
<GlyphID id="68" name="u1F1FE"/>
<GlyphID id="69" name="u1F1FF"/>
</GlyphOrder> </GlyphOrder>
<head> <head>
@ -71,7 +97,7 @@
</head> </head>
<hhea> <hhea>
<tableVersion value="1.0"/> <tableVersion value="0x00010000"/>
<ascent value="1900"/> <ascent value="1900"/>
<descent value="-500"/> <descent value="-500"/>
<lineGap value="0"/> <lineGap value="0"/>
@ -93,7 +119,7 @@
<maxp> <maxp>
<!-- Most of this table will be recalculated by the compiler --> <!-- Most of this table will be recalculated by the compiler -->
<tableVersion value="0x10000"/> <tableVersion value="0x10000"/>
<numGlyphs value="30"/> <numGlyphs value="70"/>
<maxPoints value="8"/> <maxPoints value="8"/>
<maxContours value="2"/> <maxContours value="2"/>
<maxCompositePoints value="0"/> <maxCompositePoints value="0"/>
@ -144,8 +170,8 @@
<ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/> <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/>
<achVendID value="GOOG"/> <achVendID value="GOOG"/>
<fsSelection value="00000000 01000000"/> <fsSelection value="00000000 01000000"/>
<fsFirstCharIndex value="0"/> <usFirstCharIndex value="0"/>
<fsLastCharIndex value="90"/> <usLastCharIndex value="65535"/>
<sTypoAscender value="1900"/> <sTypoAscender value="1900"/>
<sTypoDescender value="-500"/> <sTypoDescender value="-500"/>
<sTypoLineGap value="0"/> <sTypoLineGap value="0"/>
@ -157,7 +183,7 @@
<sCapHeight value="1900"/> <sCapHeight value="1900"/>
<usDefaultChar value="0"/> <usDefaultChar value="0"/>
<usBreakChar value="32"/> <usBreakChar value="32"/>
<usMaxContex value="1"/> <usMaxContext value="1"/>
</OS_2> </OS_2>
<hmtx> <hmtx>
@ -205,6 +231,32 @@
<mtx name="uE007F" width="0" lsb="0"/> <mtx name="uE007F" width="0" lsb="0"/>
<mtx name="u1F3F4" width="0" lsb="0"/> <mtx name="u1F3F4" width="0" lsb="0"/>
<mtx name="uFE82B" width="0" lsb="0"/> <mtx name="uFE82B" width="0" lsb="0"/>
<mtx name="u1F1E6" width="0" lsb="0"/>
<mtx name="u1F1E7" width="0" lsb="0"/>
<mtx name="u1F1E8" width="0" lsb="0"/>
<mtx name="u1F1E9" width="0" lsb="0"/>
<mtx name="u1F1EA" width="0" lsb="0"/>
<mtx name="u1F1EB" width="0" lsb="0"/>
<mtx name="u1F1EC" width="0" lsb="0"/>
<mtx name="u1F1ED" width="0" lsb="0"/>
<mtx name="u1F1EE" width="0" lsb="0"/>
<mtx name="u1F1EF" width="0" lsb="0"/>
<mtx name="u1F1F0" width="0" lsb="0"/>
<mtx name="u1F1F1" width="0" lsb="0"/>
<mtx name="u1F1F2" width="0" lsb="0"/>
<mtx name="u1F1F3" width="0" lsb="0"/>
<mtx name="u1F1F4" width="0" lsb="0"/>
<mtx name="u1F1F5" width="0" lsb="0"/>
<mtx name="u1F1F6" width="0" lsb="0"/>
<mtx name="u1F1F7" width="0" lsb="0"/>
<mtx name="u1F1F8" width="0" lsb="0"/>
<mtx name="u1F1F9" width="0" lsb="0"/>
<mtx name="u1F1FA" width="0" lsb="0"/>
<mtx name="u1F1FB" width="0" lsb="0"/>
<mtx name="u1F1FC" width="0" lsb="0"/>
<mtx name="u1F1FD" width="0" lsb="0"/>
<mtx name="u1F1FE" width="0" lsb="0"/>
<mtx name="u1F1FF" width="0" lsb="0"/>
</hmtx> </hmtx>
<cmap> <cmap>
@ -253,6 +305,32 @@
<map code="0xE007F" name="uE007F"/> <map code="0xE007F" name="uE007F"/>
<map code="0x1F3F4" name="u1F3F4"/> <map code="0x1F3F4" name="u1F3F4"/>
<map code="0xFE82B" name="uFE82B"/> <map code="0xFE82B" name="uFE82B"/>
<map code="0x1F1E6" name="u1F1E6"/>
<map code="0x1F1E7" name="u1F1E7"/>
<map code="0x1F1E8" name="u1F1E8"/>
<map code="0x1F1E9" name="u1F1E9"/>
<map code="0x1F1EA" name="u1F1EA"/>
<map code="0x1F1EB" name="u1F1EB"/>
<map code="0x1F1EC" name="u1F1EC"/>
<map code="0x1F1ED" name="u1F1ED"/>
<map code="0x1F1EE" name="u1F1EE"/>
<map code="0x1F1EF" name="u1F1EF"/>
<map code="0x1F1F0" name="u1F1F0"/>
<map code="0x1F1F1" name="u1F1F1"/>
<map code="0x1F1F2" name="u1F1F2"/>
<map code="0x1F1F3" name="u1F1F3"/>
<map code="0x1F1F4" name="u1F1F4"/>
<map code="0x1F1F5" name="u1F1F5"/>
<map code="0x1F1F6" name="u1F1F6"/>
<map code="0x1F1F7" name="u1F1F7"/>
<map code="0x1F1F8" name="u1F1F8"/>
<map code="0x1F1F9" name="u1F1F9"/>
<map code="0x1F1FA" name="u1F1FA"/>
<map code="0x1F1FB" name="u1F1FB"/>
<map code="0x1F1FC" name="u1F1FC"/>
<map code="0x1F1FD" name="u1F1FD"/>
<map code="0x1F1FE" name="u1F1FE"/>
<map code="0x1F1FF" name="u1F1FF"/>
</cmap_format_12> </cmap_format_12>
</cmap> </cmap>
@ -337,18 +415,18 @@
<FeatureRecord index="0"> <FeatureRecord index="0">
<FeatureTag value="ccmp"/> <FeatureTag value="ccmp"/>
<Feature> <Feature>
<!-- LookupCount=1 --> <!-- LookupCount=4 -->
<LookupListIndex index="0" value="0"/> <LookupListIndex index="0" value="0"/>
<LookupListIndex index="1" value="2"/> <LookupListIndex index="1" value="2"/>
<LookupListIndex index="2" value="3"/> <LookupListIndex index="2" value="3"/>
<LookupListIndex index="3" value="4"/>
</Feature> </Feature>
</FeatureRecord> </FeatureRecord>
</FeatureList> </FeatureList>
<LookupList> <LookupList>
<!-- LookupCount=1 --> <!-- LookupCount=5 -->
<Lookup index="0"> <Lookup index="0">
<LookupType value="4"/> <LookupType value="4"/>
<!-- LookupType=4 -->
<LookupFlag value="0"/> <LookupFlag value="0"/>
<!-- SubTableCount=1 --> <!-- SubTableCount=1 -->
<LigatureSubst index="0" Format="1"> <LigatureSubst index="0" Format="1">
@ -359,6 +437,32 @@
<LookupFlag value="0"/> <LookupFlag value="0"/>
<!-- SubTableCount=1 --> <!-- SubTableCount=1 -->
<MultipleSubst index="0" Format="1"> <MultipleSubst index="0" Format="1">
<Substitution in="u1F1E6" out=""/>
<Substitution in="u1F1E7" out=""/>
<Substitution in="u1F1E8" out=""/>
<Substitution in="u1F1E9" out=""/>
<Substitution in="u1F1EA" out=""/>
<Substitution in="u1F1EB" out=""/>
<Substitution in="u1F1EC" out=""/>
<Substitution in="u1F1ED" out=""/>
<Substitution in="u1F1EE" out=""/>
<Substitution in="u1F1EF" out=""/>
<Substitution in="u1F1F0" out=""/>
<Substitution in="u1F1F1" out=""/>
<Substitution in="u1F1F2" out=""/>
<Substitution in="u1F1F3" out=""/>
<Substitution in="u1F1F4" out=""/>
<Substitution in="u1F1F5" out=""/>
<Substitution in="u1F1F6" out=""/>
<Substitution in="u1F1F7" out=""/>
<Substitution in="u1F1F8" out=""/>
<Substitution in="u1F1F9" out=""/>
<Substitution in="u1F1FA" out=""/>
<Substitution in="u1F1FB" out=""/>
<Substitution in="u1F1FC" out=""/>
<Substitution in="u1F1FD" out=""/>
<Substitution in="u1F1FE" out=""/>
<Substitution in="u1F1FF" out=""/>
<Substitution in="uE0030" out=""/> <Substitution in="uE0030" out=""/>
<Substitution in="uE0031" out=""/> <Substitution in="uE0031" out=""/>
<Substitution in="uE0032" out=""/> <Substitution in="uE0032" out=""/>
@ -399,7 +503,6 @@
</Lookup> </Lookup>
<Lookup index="2"> <Lookup index="2">
<LookupType value="6"/> <LookupType value="6"/>
<!-- LookupType=6 -->
<LookupFlag value="0"/> <LookupFlag value="0"/>
<!-- SubTableCount=1 --> <!-- SubTableCount=1 -->
<ChainContextSubst index="0" Format="2"> <ChainContextSubst index="0" Format="2">
@ -495,7 +598,7 @@
<Backtrack index="0" value="1"/> <Backtrack index="0" value="1"/>
<!-- InputGlyphCount=1 --> <!-- InputGlyphCount=1 -->
<!-- LookAheadGlyphCount=0 --> <!-- LookAheadGlyphCount=0 -->
<!-- SubstCount=2 --> <!-- SubstCount=1 -->
<SubstLookupRecord index="0"> <SubstLookupRecord index="0">
<SequenceIndex value="0"/> <SequenceIndex value="0"/>
<LookupListIndex value="1"/> <LookupListIndex value="1"/>
@ -507,6 +610,7 @@
<Lookup index="3"> <Lookup index="3">
<LookupType value="4"/> <LookupType value="4"/>
<LookupFlag value="0"/> <LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<LigatureSubst index="0" Format="1"> <LigatureSubst index="0" Format="1">
<LigatureSet glyph="u1F3F4"> <LigatureSet glyph="u1F3F4">
<Ligature components="uE007F" glyph="uFE82B"/> <Ligature components="uE007F" glyph="uFE82B"/>
@ -516,6 +620,119 @@
</LigatureSet> </LigatureSet>
</LigatureSubst> </LigatureSubst>
</Lookup> </Lookup>
<Lookup index="4">
<LookupType value="5"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<ContextSubst index="0" Format="2">
<Coverage Format="2">
<Glyph value="u1F1E6"/>
<Glyph value="u1F1E7"/>
<Glyph value="u1F1E8"/>
<Glyph value="u1F1E9"/>
<Glyph value="u1F1EA"/>
<Glyph value="u1F1EB"/>
<Glyph value="u1F1EC"/>
<Glyph value="u1F1ED"/>
<Glyph value="u1F1EE"/>
<Glyph value="u1F1EF"/>
<Glyph value="u1F1F0"/>
<Glyph value="u1F1F1"/>
<Glyph value="u1F1F2"/>
<Glyph value="u1F1F3"/>
<Glyph value="u1F1F4"/>
<Glyph value="u1F1F5"/>
<Glyph value="u1F1F6"/>
<Glyph value="u1F1F7"/>
<Glyph value="u1F1F8"/>
<Glyph value="u1F1F9"/>
<Glyph value="u1F1FA"/>
<Glyph value="u1F1FB"/>
<Glyph value="u1F1FC"/>
<Glyph value="u1F1FD"/>
<Glyph value="u1F1FE"/>
<Glyph value="u1F1FF"/>
</Coverage>
<ClassDef Format="2">
<ClassDef glyph="u1F1E6" class="1"/>
<ClassDef glyph="u1F1E7" class="1"/>
<ClassDef glyph="u1F1E8" class="1"/>
<ClassDef glyph="u1F1E9" class="1"/>
<ClassDef glyph="u1F1EA" class="1"/>
<ClassDef glyph="u1F1EB" class="1"/>
<ClassDef glyph="u1F1EC" class="1"/>
<ClassDef glyph="u1F1ED" class="1"/>
<ClassDef glyph="u1F1EE" class="1"/>
<ClassDef glyph="u1F1EF" class="1"/>
<ClassDef glyph="u1F1F0" class="1"/>
<ClassDef glyph="u1F1F1" class="1"/>
<ClassDef glyph="u1F1F2" class="1"/>
<ClassDef glyph="u1F1F3" class="1"/>
<ClassDef glyph="u1F1F4" class="1"/>
<ClassDef glyph="u1F1F5" class="1"/>
<ClassDef glyph="u1F1F6" class="1"/>
<ClassDef glyph="u1F1F7" class="1"/>
<ClassDef glyph="u1F1F8" class="1"/>
<ClassDef glyph="u1F1F9" class="1"/>
<ClassDef glyph="u1F1FA" class="1"/>
<ClassDef glyph="u1F1FB" class="1"/>
<ClassDef glyph="u1F1FC" class="1"/>
<ClassDef glyph="u1F1FD" class="1"/>
<ClassDef glyph="u1F1FE" class="1"/>
<ClassDef glyph="u1F1FF" class="1"/>
</ClassDef>
<!-- SubClassSetCount=2 -->
<SubClassSet index="0" empty="1"/>
<SubClassSet index="1">
<!-- SubClassRuleCount=1 -->
<SubClassRule index="0">
<!-- GlyphCount=2 -->
<!-- SubstCount=2 -->
<Class index="0" value="1"/>
<SubstLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="5"/>
</SubstLookupRecord>
<SubstLookupRecord index="1">
<SequenceIndex value="1"/>
<LookupListIndex value="1"/>
</SubstLookupRecord>
</SubClassRule>
</SubClassSet>
</ContextSubst>
</Lookup>
<Lookup index="5">
<LookupType value="1"/>
<LookupFlag value="0"/>
<SingleSubst index="0" Format="1">
<Substitution in="u1F1E6" out="uFE82B"/>
<Substitution in="u1F1E7" out="uFE82B"/>
<Substitution in="u1F1E8" out="uFE82B"/>
<Substitution in="u1F1E9" out="uFE82B"/>
<Substitution in="u1F1EA" out="uFE82B"/>
<Substitution in="u1F1EB" out="uFE82B"/>
<Substitution in="u1F1EC" out="uFE82B"/>
<Substitution in="u1F1ED" out="uFE82B"/>
<Substitution in="u1F1EE" out="uFE82B"/>
<Substitution in="u1F1EF" out="uFE82B"/>
<Substitution in="u1F1F0" out="uFE82B"/>
<Substitution in="u1F1F1" out="uFE82B"/>
<Substitution in="u1F1F2" out="uFE82B"/>
<Substitution in="u1F1F3" out="uFE82B"/>
<Substitution in="u1F1F4" out="uFE82B"/>
<Substitution in="u1F1F5" out="uFE82B"/>
<Substitution in="u1F1F6" out="uFE82B"/>
<Substitution in="u1F1F7" out="uFE82B"/>
<Substitution in="u1F1F8" out="uFE82B"/>
<Substitution in="u1F1F9" out="uFE82B"/>
<Substitution in="u1F1FA" out="uFE82B"/>
<Substitution in="u1F1FB" out="uFE82B"/>
<Substitution in="u1F1FC" out="uFE82B"/>
<Substitution in="u1F1FD" out="uFE82B"/>
<Substitution in="u1F1FE" out="uFE82B"/>
<Substitution in="u1F1FF" out="uFE82B"/>
</SingleSubst>
</Lookup>
</LookupList> </LookupList>
</GSUB> </GSUB>

View file

@ -160,7 +160,7 @@ glyph_names = set()
ligatures = {} ligatures = {}
def add_lig_sequence(ligatures, seq, n): 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 # ZWJ, fitzpatrick modifiers, and combinations of ZWJ and fitzpatrick
# modifiers. Currently, Harfbuzz special-cases the fitzpatrick # modifiers. Currently, Harfbuzz special-cases the fitzpatrick
# modifiers to treat them as combining marks instead of as Other # 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 # emoji sequences in an RTL context we need GSUB sequences that match
# this order. # this order.
# Regional indicator symbols are LTR, and emoji+fitzpatrick are # Regional indicator symbols are LTR, and emoji+fitzpatrick are
# effectively LTR, so we only reorder sequences with ZWJ. If however # effectively LTR, so we only reorder sequences with ZWJ or tags. If
# the ZWJ sequence has fitzpatrick modifiers, those need to still follow # however the ZWJ sequence has fitzpatrick modifiers, those need to
# the emoji they logically follow, so simply reversing the sequence # still follow the emoji they logically follow, so simply reversing the
# doesn't work. This code assumes the lig sequence is valid. # sequence doesn't work. This code assumes the lig sequence is valid.
tseq = tuple(seq) tseq = tuple(seq)
if tseq in ligatures: if tseq in ligatures:
print 'lig sequence %s, replace %s with %s' % ( print 'lig sequence %s, replace %s with %s' % (
@ -261,15 +261,6 @@ if have_flags:
name = _reg_lig_name(flag_to) name = _reg_lig_name(flag_to)
add_lig_sequence(ligatures, seq, name) 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) keyed_ligatures = collections.defaultdict(list)
for k, v in ligatures.iteritems(): for k, v in ligatures.iteritems():
first = k[0] first = k[0]