ws-arch: font/woff and font/woff2 (glyf/loca/hmtx transforms) with tests: identical glyphs to the sfnt

This commit is contained in:
4DBug committed 2026-10-31 08:42:57 -05:00
1 parent e55f8a9a0d
commit ef6c658d78
9 files changed
+964 -2

No files matched your search

+5 -1
View File
@@ -148,6 +148,10 @@ def flavors(data):
b = io.BytesIO()
f.save(b)
out[fl] = b64(b.getvalue())
from fontTools.ttLib import woff2
src, dst = io.BytesIO(data), io.BytesIO()
woff2.compress(src, dst, transform_tables={"glyf", "loca", "hmtx"})
out["woff2h"] = b64(dst.getvalue())
return out
@@ -170,7 +174,7 @@ def main():
# woff / woff2 of every font (the reference values are the sfnt's own)
for name, data in fonts.items():
fl = flavors(data)
res["woff"].append({"name": name, "woff": fl["woff"], "woff2": fl["woff2"]})
res["woff"].append({"name": name, "woff": fl["woff"], "woff2": fl["woff2"], "woff2h": fl["woff2h"]})
json.dump(res, sys.stdout)
+1 -1
View File
@@ -31,7 +31,7 @@ def generate(ctx):
for r in f["renders"]:
r["pixels"] = d(r["pixels"])
for w in res["woff"]:
w["woff"], w["woff2"] = d(w["woff"]), d(w["woff2"])
w["woff"], w["woff2"], w["woff2h"] = d(w["woff"]), d(w["woff2"]), d(w["woff2h"])
if "ttc" in res:
res["ttc"]["data"] = d(res["ttc"]["data"])
ctx.emit("fonts", res)