forked from googlefonts/noto-emoji
-
Notifications
You must be signed in to change notification settings - Fork 0
/
about_fonts.py
37 lines (25 loc) · 1 KB
/
about_fonts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Prints info about emoji fonts."""
from fontTools import ttLib
from pathlib import Path
import sys
NAME_ID_VERSION = 5
def name(font, name_id):
return ",".join(n.toUnicode() for n in font["name"].names if n.isUnicode() and n.nameID == name_id)
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.append(f"fontRevision:{font['head'].fontRevision:.3f}")
font_type.append(name(font, NAME_ID_VERSION))
font_type = ", ".join(font_type)
print(f"{font_file.name:{max_name_len + 1}} {font_type}")
if __name__ == '__main__':
main()