chiark / gitweb /
compatcheck: detect vanished code points from fonts
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 14 Dec 2024 16:41:51 +0000 (16:41 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 14 Dec 2024 16:43:06 +0000 (16:43 +0000)
compatcheck

index e96e76617c0bff57d9ea9332719ebd2841f6d0d4..a11478f36e9c9700b07e8edd700753a1968a618a 100755 (executable)
@@ -24,5 +24,15 @@ if not (set(ttold.getGlyphOrder()) <= set(ttnew.getGlyphOrder())):
    fail("Glyphs vanished: "
         f"{set(ttold.getGlyphOrder()) - set(ttnew.getGlyphOrder())!r}")
 
+for cmapold in ttold['cmap'].tables:
+    cmapnew = ttnew['cmap'].getcmap(cmapold.platformID, cmapold.platEncID)
+    if cmapnew == None:
+        fail("No cmap in new font for "
+             f"{(cmapold.platformID,cmapold.platEncID)}")
+    elif not (set(cmapold.cmap.keys()) <= set(cmapnew.cmap.keys())):
+        fail("Code points vanished from "
+             f"{(cmapold.platformID,cmapold.platEncID)}: "
+             f"{set(cmapold.cmap.keys()) - set(cmapnew.cmap.keys())!r}")
+
 if failed:
     exit(1)