mirror of
https://bjh21.me.uk/bedstead/.git
synced 2026-07-09 21:43:06 -04:00
39 lines
1.0 KiB
Python
Executable File
39 lines
1.0 KiB
Python
Executable File
#! /usr/bin/python3
|
|
|
|
# SPDX-License-Identifier: CC0-1.0
|
|
|
|
from argparse import ArgumentParser
|
|
from fontTools import ttLib
|
|
from sys import exit
|
|
|
|
parser = ArgumentParser()
|
|
parser.add_argument("old")
|
|
parser.add_argument("new")
|
|
|
|
cfg = parser.parse_args()
|
|
|
|
ttold = ttLib.TTFont(cfg.old)
|
|
ttnew = ttLib.TTFont(cfg.new)
|
|
|
|
failed = False
|
|
|
|
def fail(msg):
|
|
print(f"FAIL: {msg}")
|
|
|
|
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)
|