From db0e3934338cf84e9af423d28ca788d62c7339ba Mon Sep 17 00:00:00 2001 From: Rod S Date: Wed, 16 Nov 2022 21:54:33 -0800 Subject: [PATCH] Ran fix_colr_font_revision.py --- about_fonts.py | 11 ++++++++- fix_colr_font_revision.py | 36 ++++++++++++++++++++++++++++++ fonts/Noto-COLRv1-emojicompat.ttf | Bin 4931580 -> 4931580 bytes fonts/Noto-COLRv1-noflags.ttf | Bin 2767876 -> 2767876 bytes fonts/Noto-COLRv1.ttf | Bin 4754692 -> 4754692 bytes 5 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 fix_colr_font_revision.py diff --git a/about_fonts.py b/about_fonts.py index d1e5bb410..c1d8d1abb 100644 --- a/about_fonts.py +++ b/about_fonts.py @@ -5,6 +5,13 @@ 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) @@ -19,7 +26,9 @@ def main(): font_type.append("COLR") if "meta" in font and "Emji" in font["meta"].data: font_type.append("EmojiCompat") - font_type = ",".join(font_type) + 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}") diff --git a/fix_colr_font_revision.py b/fix_colr_font_revision.py new file mode 100644 index 000000000..76b65b72b --- /dev/null +++ b/fix_colr_font_revision.py @@ -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() diff --git a/fonts/Noto-COLRv1-emojicompat.ttf b/fonts/Noto-COLRv1-emojicompat.ttf index c67132dfb96ce7ac312b5bc7668e92284fd929bf..c93afb11c9a6572a62733007f2d0ab6ec1b2658e 100644 GIT binary patch delta 354 zcmW;7IWj{50D$3__hLybv9BSBeSP*ViP*Ps1}9LM(W(?$YU2hvg&BMwXb~f`v1@6tj8 diff --git a/fonts/Noto-COLRv1-noflags.ttf b/fonts/Noto-COLRv1-noflags.ttf index 3487ad881371e2999ec91db1d8c591149808ad7b..daa7629e8ba1dbcb8d2b291a8c573bb1baa78b5c 100644 GIT binary patch delta 222 zcmW;7ISRr+06@{1Ok5I|823HnzMMcrv9R$Lo^v4g6 z?|*O7$7!S9wtLro9#9qsTmLUTQCL)L;hBz$PNFa$6 r(r}Q0i!5@;qktkxD5HWZYN(@uCOl}g&_)Mc^w7ruLyYcPj$hLsKoBtU delta 222 zcmXBFISxTl7(n6syU#p4^US;EVF^O$#44;oqE~o{im(E$9oT?UY(ZlI8i~?*agr~` z{a(byaitHp`Dwj(M5)E*abMcwkJ6U%dQPV2|7Y*5k)08b4;mKy2q1_M!iXS>7~)94 pMiMEckwF$YFBP=%tT-1{h?BVe%x5Fv=L?Ofbn5)66i-9P=!&$P&w}u*w?i hY_Q1|+w8E*9tDc*Q=-fPha7Rt38$RBC*k?`!yjRQObGx0 delta 342 zcmXZNNiIVH0D$55`l{yEShGGet$7|=ic%YAa0ZDRXksCxwiXsH;R4RVf-Bhjn)FY; z{I%EjM2-4w^!)kra`%)AgCO;mt>0vde?gQC8hw|_*Uf+3$KgX9HYA8h(n5+>+GwYP zPP*tOO@7$