# SPDX-License-Identifier: AGPL-3.0-only
"""Reconstructed 2026-10-17; not a record of the original build command.
With FontTools 4.61.1 and the source OTF hashes in verified-hashes.json,
this reproduces all three shipped WOFFs byte-for-byte. Recorded head.modified
values are copied from the shipped files; they are not independently proven
creation dates. This procedure writes only to the output directory you select.
Usage: python rebuild_fonts.py SOURCE_OTF_DIRECTORY OUTPUT_DIRECTORY
"""
from pathlib import Path
from fontTools import subset
from fontTools.ttLib import TTFont
import sys
source, output = map(Path, sys.argv[1:3])
output.mkdir(parents=True, exist_ok=True)
codepoints = list(range(0x20, 0x7f)) + list(range(0xa0, 0x100)) + [0x2013, 0x2014, 0x2019, 0x201c, 0x201d, 0x2193, 0x2197]
for filename, original, modified in [
    ('editorial.woff', 'NimbusRoman-Regular.otf', 3874672586),
    ('sans.woff', 'NimbusSans-Regular.otf', 3874672587),
    ('editorial-italic.woff', 'NimbusRoman-Italic.otf', 3874672587),
]:
    font = TTFont(source / original, recalcTimestamp=False)
    worker = subset.Subsetter(options=subset.Options())
    worker.populate(unicodes=codepoints)
    worker.subset(font)
    font['head'].modified = modified
    font.flavor = 'woff'
    font.save(output / filename, reorderTables=True)
