# EOT fixtures (tools/fixtures.py): no EOT tool is packaged in nixpkgs, so Embedded OpenType files are built here per # the W3C EOT submission (versions 1.0, 2.1 plain and XOR-obfuscated, 2.2 with an empty signature and EUDC data, one # MTX-flagged file) around TrueType / CFF fonts (DejaVu Sans Mono from nixpkgs#dejavu_fonts, Source Sans 3 OTF from # nixpkgs#source-sans); the header fields come from fontTools, and the inner font's facts (units per em, glyph count, # cmap glyph ids, advances) from fontTools too. # tests/gen/eot.luau { cases = { { name, data, version, xor, family, style, fullName, weight, fsType, upem, # numGlyphs, glyphs = { { cp, gid, advance } } } }, mtx } import json, os, struct, subprocess CODE = r''' import json, sys from fontTools.ttLib import TTFont out = [] for p in json.load(sys.stdin): f = TTFont(p) os2, head, name = f["OS/2"], f["head"], f["name"] cmap = f.getBestCmap() glyphs = [] order = f.getGlyphOrder() for cp in (65, 97, 48, 0x20AC, 0x3A9): if cp in cmap: g = cmap[cp] glyphs.append({"cp": cp, "gid": order.index(g), "advance": f["hmtx"][g][0]}) out.append({"panose": bytes([getattr(os2.panose, k) for k in ("bFamilyType", "bSerifStyle", "bWeight", "bProportion", "bContrast", "bStrokeVariation", "bArmStyle", "bLetterForm", "bMidline", "bXHeight")]).hex(), "weight": os2.usWeightClass, "fsType": os2.fsType, "italic": os2.fsSelection & 1, "ranges": [os2.ulUnicodeRange1, os2.ulUnicodeRange2, os2.ulUnicodeRange3, os2.ulUnicodeRange4], "codepages": [getattr(os2, "ulCodePageRange1", 0), getattr(os2, "ulCodePageRange2", 0)], "checksum": head.checkSumAdjustment, "upem": head.unitsPerEm, "numGlyphs": len(order), "family": name.getDebugName(1) or "", "style": name.getDebugName(2) or "", "version": name.getDebugName(5) or "", "full": name.getDebugName(4) or "", "glyphs": glyphs}) print(json.dumps(out)) ''' def store(pkg): return subprocess.run(["nix", "build", "--no-link", "--print-out-paths", "nixpkgs#" + pkg], capture_output=True, check=True, text=True).stdout.strip().split("\n")[-1] def utf16(s): return s.encode("utf-16-le") def eot(data, facts, version, xor=False, flags=0): hdr = struct.pack("= 0x00020001: u = utf16("https://example.com/") hdr += struct.pack("