Ran fix_colr_font_revision.py
parent
e8f3ab2060
commit
db0e393433
|
@ -5,6 +5,13 @@ from pathlib import Path
|
||||||
import sys
|
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():
|
def main():
|
||||||
font_files = sorted(p for p in (Path(__file__).parent / "fonts").iterdir() if p.suffix == ".ttf")
|
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)
|
max_name_len = max(len(p.name) for p in font_files)
|
||||||
|
@ -19,6 +26,8 @@ def main():
|
||||||
font_type.append("COLR")
|
font_type.append("COLR")
|
||||||
if "meta" in font and "Emji" in font["meta"].data:
|
if "meta" in font and "Emji" in font["meta"].data:
|
||||||
font_type.append("EmojiCompat")
|
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)
|
font_type = ", ".join(font_type)
|
||||||
|
|
||||||
print(f"{font_file.name:{max_name_len + 1}} {font_type}")
|
print(f"{font_file.name:{max_name_len + 1}} {font_type}")
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
"""Set COLRv1 fontRevision from CBDT.
|
||||||
|
|
||||||
|
Used for bugfix, should fix to set properly on build instead.
|
||||||
|
"""
|
||||||
|
|
||||||
|
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():
|
||||||
|
colr_font_files = sorted(p for p in (Path(__file__).parent / "fonts").iterdir() if p.name.startswith("Noto-COLRv1"))
|
||||||
|
|
||||||
|
for colr_font_file in colr_font_files:
|
||||||
|
cbdt_font_file = colr_font_file.with_stem(colr_font_file.stem.replace("Noto-COLRv1", "NotoColorEmoji"))
|
||||||
|
|
||||||
|
colr_font = ttLib.TTFont(colr_font_file)
|
||||||
|
cbdt_font = ttLib.TTFont(cbdt_font_file)
|
||||||
|
|
||||||
|
assert "CBDT" in cbdt_font
|
||||||
|
assert "COLR" in colr_font
|
||||||
|
|
||||||
|
colr_font["head"].fontRevision = cbdt_font["head"].fontRevision
|
||||||
|
|
||||||
|
colr_font.save(colr_font_file)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue