mirror of
https://github.com/googlefonts/noto-emoji.git
synced 2025-06-08 07:47:59 +00:00
Improve flag support.
This adds some additional flags to the default set. In addition, it contains code that creates ligatures for some flag sequences to others, for a few cases where we want different regions to share the same flag. Finally, it adds default ligatures so that pairs of regional indicator characters for which there's no predefined glyph get a 'missing flag' glyph. This avoids cases where sequences of regional indicator sequences accidentally match at odd locations because of a previous mismatch. There is no actual 'missing flag' glyph yet. The code uses an existing emoji as a placeholder.
This commit is contained in:
parent
0b5cf8651b
commit
3a57df2ac6
2 changed files with 60 additions and 5 deletions
8
Makefile
8
Makefile
|
@ -44,7 +44,7 @@ QUANTIZED_DIR := $(BUILD_DIR)/quantized_pngs
|
||||||
COMPRESSED_DIR := $(BUILD_DIR)/compressed_pngs
|
COMPRESSED_DIR := $(BUILD_DIR)/compressed_pngs
|
||||||
|
|
||||||
LIMITED_FLAGS = CN DE ES FR GB IT JP KR RU US
|
LIMITED_FLAGS = CN DE ES FR GB IT JP KR RU US
|
||||||
SELECTED_FLAGS = AD AE AF AG AI AL AM AO AR AS AT AU AW AX AZ \
|
SELECTED_FLAGS = AC AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ \
|
||||||
BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BW BY BZ \
|
BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BW BY BZ \
|
||||||
CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ \
|
CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ \
|
||||||
DE DJ DK DM DO DZ \
|
DE DJ DK DM DO DZ \
|
||||||
|
@ -52,7 +52,7 @@ SELECTED_FLAGS = AD AE AF AG AI AL AM AO AR AS AT AU AW AX AZ \
|
||||||
FI FJ FM FO FR \
|
FI FJ FM FO FR \
|
||||||
GA GB GD GE GG GH GI GL GM GN GQ GR GT GU GW GY \
|
GA GB GD GE GG GH GI GL GM GN GQ GR GT GU GW GY \
|
||||||
HK HN HR HT HU \
|
HK HN HR HT HU \
|
||||||
ID IE IL IM IN IO IQ IR IS IT \
|
IC ID IE IL IM IN IO IQ IR IS IT \
|
||||||
JE JM JO JP \
|
JE JM JO JP \
|
||||||
KE KG KH KI KM KN KP KR KW KY KZ \
|
KE KG KH KI KM KN KP KR KW KY KZ \
|
||||||
LA LB LC LI LK LR LS LT LU LV LY \
|
LA LB LC LI LK LR LS LT LU LV LY \
|
||||||
|
@ -62,8 +62,8 @@ SELECTED_FLAGS = AD AE AF AG AI AL AM AO AR AS AT AU AW AX AZ \
|
||||||
PA PE PF PG PH PK PL PN PR PS PT PW PY \
|
PA PE PF PG PH PK PL PN PR PS PT PW PY \
|
||||||
QA \
|
QA \
|
||||||
RO RS RU RW \
|
RO RS RU RW \
|
||||||
SA SB SC SD SE SG SI SK SL SM SN SO SR SS ST SV SX SY SZ \
|
SA SB SC SD SE SG SH SI SK SL SM SN SO SR SS ST SV SX SY SZ \
|
||||||
TC TD TG TH TJ TK TL TM TN TO TR TT TV TW TZ \
|
TA TC TD TG TH TJ TK TL TM TN TO TR TT TV TW TZ \
|
||||||
UA UG US UY UZ \
|
UA UG US UY UZ \
|
||||||
VA VC VE VG VI VN VU \
|
VA VC VE VG VI VN VU \
|
||||||
WS \
|
WS \
|
||||||
|
|
57
third_party/color_emoji/add_glyphs.py
vendored
57
third_party/color_emoji/add_glyphs.py
vendored
|
@ -1,10 +1,13 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import collections, glob, os, sys
|
import collections, glob, os, re, sys
|
||||||
from fontTools import ttx
|
from fontTools import ttx
|
||||||
from fontTools.ttLib.tables import otTables
|
from fontTools.ttLib.tables import otTables
|
||||||
from png import PNG
|
from png import PNG
|
||||||
|
|
||||||
|
# TODO: replace with actual name once we have a glyph.
|
||||||
|
MISSING_FLAG_GLYPH_NAME = "u2764"
|
||||||
|
|
||||||
sys.path.append(
|
sys.path.append(
|
||||||
os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
|
os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
|
||||||
import add_emoji_gsub
|
import add_emoji_gsub
|
||||||
|
@ -78,6 +81,15 @@ EXTRA_SEQUENCES = {
|
||||||
'u1F48F': '1F469_200D_2764_FE0F_200D_1F48B_200D_1F468', # WHKM
|
'u1F48F': '1F469_200D_2764_FE0F_200D_1F48B_200D_1F468', # WHKM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Flag aliases - from: to
|
||||||
|
FLAG_ALIASES = {
|
||||||
|
'BV': 'NO',
|
||||||
|
'SJ': 'NO',
|
||||||
|
'UM': 'FR',
|
||||||
|
'HM': 'AU',
|
||||||
|
'UM': 'US',
|
||||||
|
}
|
||||||
|
|
||||||
if len (sys.argv) < 4:
|
if len (sys.argv) < 4:
|
||||||
print >>sys.stderr, """
|
print >>sys.stderr, """
|
||||||
Usage:
|
Usage:
|
||||||
|
@ -180,6 +192,49 @@ for n in EXTRA_SEQUENCES:
|
||||||
else:
|
else:
|
||||||
print 'extras: no glyph for %s' % n
|
print 'extras: no glyph for %s' % n
|
||||||
|
|
||||||
|
# Add missing regional indicator sequences and flag aliases
|
||||||
|
# if we support any.
|
||||||
|
regional_names = frozenset('u%X' % cp for cp in range(0x1F1E6, 0x1F200))
|
||||||
|
|
||||||
|
def _is_flag_sequence(t):
|
||||||
|
return len(t) == 2 and t[0] in regional_names and t[1] in regional_names
|
||||||
|
|
||||||
|
have_flags = False
|
||||||
|
for k in ligatures:
|
||||||
|
if _is_flag_sequence(k):
|
||||||
|
have_flags = True
|
||||||
|
break
|
||||||
|
|
||||||
|
# sigh, too many separate files with the same code.
|
||||||
|
# copied from add_emoji_gsub.
|
||||||
|
def _reg_indicator(letter):
|
||||||
|
assert 'A' <= letter <= 'Z'
|
||||||
|
return 0x1F1E6 + ord(letter) - ord('A')
|
||||||
|
|
||||||
|
def _reg_lig_sequence(flag_name):
|
||||||
|
"""Returns a tuple of strings naming the codepoints that form the ligature."""
|
||||||
|
assert len(flag_name) == 2
|
||||||
|
return tuple('u%X' % _reg_indicator(cp) for cp in flag_name)
|
||||||
|
|
||||||
|
def _reg_lig_name(flag_name):
|
||||||
|
"""Returns a glyph name for the flag name."""
|
||||||
|
return '_'.join(_reg_lig_sequence(flag_name))
|
||||||
|
|
||||||
|
if have_flags:
|
||||||
|
print 'Adding flag aliases.'
|
||||||
|
for flag_from, flag_to in FLAG_ALIASES.iteritems():
|
||||||
|
seq = _reg_lig_sequence(flag_from)
|
||||||
|
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, MISSING_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():
|
||||||
|
|
Loading…
Add table
Reference in a new issue