Add emojicompat metadata
parent
9090ff0673
commit
e8f3ab2060
|
@ -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()
|
|
@ -23,23 +23,17 @@ def main(argv):
|
||||||
assert font_file.is_file(), font_file
|
assert font_file.is_file(), font_file
|
||||||
noflags_file = font_file.with_stem(font_file.stem + "-noflags")
|
noflags_file = font_file.with_stem(font_file.stem + "-noflags")
|
||||||
|
|
||||||
font = ttLib.TTFont(font_file)
|
|
||||||
if noflags_file.is_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
|
continue
|
||||||
|
|
||||||
|
font = ttLib.TTFont(font_file)
|
||||||
|
|
||||||
cps = codepoints(font)
|
cps = codepoints(font)
|
||||||
cps_without_flags = {cp for cp in cps if not is_regional_indicator(cp)}
|
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:
|
if cps == cps_without_flags:
|
||||||
print(font_file, f"({font_type}) has no regional indicators")
|
print(font_file, "has no regional indicators")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
subsetter = subset.Subsetter()
|
subsetter = subset.Subsetter()
|
||||||
|
@ -47,7 +41,7 @@ def main(argv):
|
||||||
subsetter.subset(font)
|
subsetter.subset(font)
|
||||||
|
|
||||||
font.save(noflags_file)
|
font.save(noflags_file)
|
||||||
print(font_file, f"({font_type}) =>" , noflags_file)
|
print(font_file, "=>" , noflags_file)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue