Skip to content

Commit

Permalink
Add emojicompat metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
rsheeter committed Nov 17, 2022
1 parent 9090ff0 commit e8f3ab2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
28 changes: 28 additions & 0 deletions about_fonts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Prints info about emoji fonts."""

from fontTools import ttLib
from pathlib import Path
import sys


def main():
font_files = sorted(p for p in (Path(__file__).parent / "fonts").iterdir() if p.suffix == ".ttf")
max_name_len = max(len(p.name) for p in font_files)

for font_file in font_files:
font = ttLib.TTFont(font_file)

font_type = []
if "CBDT" in font:
font_type.append("CBDT")
if "COLR" in font:
font_type.append("COLR")
if "meta" in font and "Emji" in font["meta"].data:
font_type.append("EmojiCompat")
font_type = ",".join(font_type)

print(f"{font_file.name:{max_name_len + 1}} {font_type}")


if __name__ == '__main__':
main()
16 changes: 5 additions & 11 deletions drop_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,25 @@ def main(argv):
assert font_file.is_file(), font_file
noflags_file = font_file.with_stem(font_file.stem + "-noflags")

font = ttLib.TTFont(font_file)
if noflags_file.is_file():
print(font_file, f"({font_type}) already has", noflags_file, "; nop")
print(font_file, "already has", noflags_file, "; nop")
continue

font = ttLib.TTFont(font_file)

cps = codepoints(font)
cps_without_flags = {cp for cp in cps if not is_regional_indicator(cp)}

font_type = []
if "CBDT" in font:
font_type.append("CBDT")
if "COLR" in font:
font_type.append("COLR")
font_type = "_".join(font_type)

if cps == cps_without_flags:
print(font_file, f"({font_type}) has no regional indicators")
print(font_file, "has no regional indicators")
continue

subsetter = subset.Subsetter()
subsetter.populate(unicodes=cps_without_flags)
subsetter.subset(font)

font.save(noflags_file)
print(font_file, f"({font_type}) =>" , noflags_file)
print(font_file, "=>" , noflags_file)


if __name__ == '__main__':
Expand Down
Binary file added fonts/Noto-COLRv1-emojicompat.ttf
Binary file not shown.
Binary file added fonts/NotoColorEmoji-emojicompat.ttf
Binary file not shown.

0 comments on commit e8f3ab2

Please sign in to comment.