Add non-regional flags

pull/378/head
Rod S 2022-01-06 20:28:57 -08:00
parent 49c85d1ac9
commit a8f13094d0
6 changed files with 80 additions and 9 deletions

View File

@ -3437,7 +3437,10 @@ srcs = [
"../svg/emoji_u303d.svg",
"../svg/emoji_u3297.svg",
"../svg/emoji_u3299.svg",
"../svg/emoji_ufe82b.svg"]
"../svg/emoji_ufe82b.svg",
"subdivision-flags/emoji_u1f3f4_e0067_e0062_e0065_e006e_e0067_e007f.svg",
"subdivision-flags/emoji_u1f3f4_e0067_e0062_e0073_e0063_e0074_e007f.svg",
"subdivision-flags/emoji_u1f3f4_e0067_e0062_e0077_e006c_e0073_e007f.svg"]
[master.regular.position]
wght = 400

View File

@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000">
<defs/>
<path fill="#FFF" d="M0,200 C173.47,114.84 346.32,145.53 521.2,171.97 C679.07,195.84 838.71,216.67 1000,137.5 L1000,737.5 C826.53,822.66 653.68,791.97 478.8,765.53 C320.93,741.66 161.29,720.83 0,800 L0,200"/>
<path fill="#CD202C" d="M440,159.8 L560,177.7 L560,777.7 L440,759.8 L440,159.8"/>
<path fill="#CD202C" d="M0,440 C173.47,354.84 346.32,385.53 521.2,411.97 C679.07,435.84 838.71,456.67 1000,377.5 L1000,497.5 C826.53,582.66 653.68,551.97 478.8,525.53 C320.93,501.66 161.29,480.83 0,560 L0,440"/>
</svg>

After

Width:  |  Height:  |  Size: 591 B

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000">
<defs/>
<path fill="#0065BD" d="M0,200 C173.47,114.84 346.32,145.53 521.2,171.97 C679.07,195.84 838.71,216.67 1000,137.5 L1000,737.5 C826.53,822.66 653.68,791.97 478.8,765.53 C320.93,741.66 161.29,720.83 0,800 L0,200"/>
<path fill="white" d="M0,200 C38.5,181.1 76.95,167.8 116.6,158.77 C243.15,206.12 369.54,300.62 500,398.75 C626.49,342.14 753.24,286.2 883.4,178.73 C921.89,169.97 960.34,156.97 1000,137.5 L1000,207.5 C873.4,345.62 746.98,422.2 616.6,485.15 C742.82,575.64 869.84,653.33 1000,667.5 L1000,737.5 C961.5,756.4 923.05,769.7 883.4,778.73 C756.85,731.38 630.46,636.88 500,538.75 C373.51,595.36 246.76,651.3 116.6,758.77 C78.11,767.53 39.66,780.53 0,800 L0,730 C126.6,591.88 253.02,515.3 383.4,452.35 C257.18,361.86 130.16,284.17 0,270 L0,200"/>
</svg>

After

Width:  |  Height:  |  Size: 834 B

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 83 KiB

View File

@ -4,7 +4,9 @@ Post-nanoemoji processing of the Noto COLRv1 Emoji file.
For now substantially based on copying from a correct bitmap build.
"""
from absl import app
import functools
from fontTools import ttLib
from fontTools.ttLib.tables import otTables as ot
import map_pua_emoji
from nototools import add_vs_cmap
from nototools import unicode_data
@ -74,6 +76,16 @@ def _lookup_in_cmap(colr_font, codepoint):
return next(iter(result))
def _add_cmap_entries(colr_font, codepoint, glyph_name):
for table in colr_font["cmap"].tables:
if _is_variation_selector_cmap_table(table):
continue
if not _is_bmp(codepoint) and table.format == 4:
continue
table.cmap[codepoint] = gn_space
print(f"Map 0x{codepoint:04x} to {glyph_name}, format {table.format}")
def _map_flag_tag_chars_to_space(colr_font):
gn_space = _lookup_in_cmap(colr_font, ord(" "))
@ -88,20 +100,56 @@ def _map_flag_tag_chars_to_space(colr_font):
# CBDT maps these things to space based on hb-shape testing
# Android fontchain_lint is unhappy if no such mapping exists
for table in colr_font["cmap"].tables:
if _is_variation_selector_cmap_table(table):
continue
for cp in tag_cps:
if not _is_bmp(cp) and table.format == 4:
continue
table.cmap[cp] = gn_space
print(f"Map 0x{cp:04x} to space, format {table.format}")
for cp in tag_cps:
_add_cmap_entries(colr_font, cp, gn_space)
def _is_bmp(cp):
return cp in range(0x0000, 0xFFFF + 1)
def _ligaset_for_glyph(lookup_list, glyph_name):
for lookup in lookup_list.Lookup:
if lookup.LookupType != 4:
continue
for liga_set in lookup.SubTable:
if glyph_name in liga_set.ligatures:
return liga_set.ligatures[glyph_name]
return None
def _Cmap(ttfont):
def _Reducer(acc, u):
acc.update(u)
return acc
unicode_cmaps = (t.cmap for t in ttfont['cmap'].tables if t.isUnicode())
return functools.reduce(_Reducer, unicode_cmaps, {})
def _map_empty_flag_tag_to_black_flag(colr_font):
# fontchain_lint wants direct support for empty flag tags
# so map them to the default flag to match cbdt behavior
# if the emoji font starts using extensions this code will require revision
cmap = _Cmap(colr_font)
black_flag_glyph = cmap[0x1f3f4]
cancel_tag_glyph = cmap[0xe007f]
lookup_list = colr_font["GSUB"].table.LookupList
liga_set = _ligaset_for_glyph(lookup_list, black_flag_glyph)
assert liga_set is not None, "There should be existing ligatures using black flag"
# Map black flag + cancel tag to just black flag
# Since this is the ligature set for black flag, component is just cancel tag
# Since we only have one component its safe to put our rule at the front
liga = ot.Ligature()
liga.Component = [cancel_tag_glyph]
liga.LigGlyph = black_flag_glyph
liga_set.insert(0, liga)
def main(argv):
if len(argv) != 3:
raise ValueError("Must have two args, a COLRv1 font and a CBDT emojicompat font")
@ -124,6 +172,8 @@ def main(argv):
_map_flag_tag_chars_to_space(colr_font)
_map_empty_flag_tag_to_black_flag(colr_font)
colr_font.save('fonts/Noto-COLRv1-noflags.ttf')

Binary file not shown.