Add emojicompat metadata

pull/409/head
Rod S 2022-11-16 21:18:23 -08:00
parent 9090ff0673
commit e8f3ab2060
4 changed files with 33 additions and 11 deletions

28
about_fonts.py 100644
View File

@ -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()

View File

@ -23,23 +23,17 @@ 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()
@ -47,7 +41,7 @@ def main(argv):
subsetter.subset(font)
font.save(noflags_file)
print(font_file, f"({font_type}) =>" , noflags_file)
print(font_file, "=>" , noflags_file)
if __name__ == '__main__':

Binary file not shown.

Binary file not shown.