Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": {
"includes": [
"**",
"!mockups",
"!**/mockups",
"!.internal",
"!**/.cache",
"!**/dist",
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"test": "bun test packages/fallbacks tools/corpus",
"corpus:acquire": "bun run tools/corpus/acquire.ts",
"corpus:compare": "bun run tools/corpus/compare.ts",
"corpus:bakeoff": "bun run tools/corpus/bakeoff.ts",
"corpus:app": "bun run tools/corpus/server.ts",
"corpus:visual": "bun run tools/corpus/visual-review.ts",
"check": "bun run typecheck && bun run test && bun run lint && bun run build",
"check:fast": "bun run typecheck && bun run lint",
"prepare": "if [ -z \"$CI\" ]; then bunx lefthook install; fi"
Expand Down
47 changes: 46 additions & 1 deletion tools/corpus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ They download fonts into an ignored cache, compare a licensed local reference ag
```sh
bun run corpus:acquire
bun run corpus:compare -- --reference /path/to/reference.ttf --family "Verdana"
bun run corpus:bakeoff -- --reference /path/to/reference.ttf --candidate "Inter=/path/to/Inter.ttf"
bun run corpus:app
```

## Acquire
Expand All @@ -35,4 +37,47 @@ bun run corpus:compare -- \
- `--model latin` is the default. Proportional Latin ranking uses text-carrying codepoints for tier, mean, and max while still reporting full Latin outliers.
- `--model monospace` reports matching mono cells as `cell_width_only`, not `metric_safe`.

Comparison output is a lead finder. A public fallback row still needs review, provenance, face-scope checks, and visual sanity.
Rows are ranked by advance tier, coverage, feature coverage (`fcov`), feature distance (`fscore`), then mean advance delta. `flags` marks strong advance matches whose font metadata disagrees enough to need review.

Comparison output is a lead finder, not a fallback decision.

## App

```sh
bun run corpus:app
```

The local app compares real reference faces against the corpus and shows the top candidates with overlays. It runs on localhost and stores temporary font files in `.cache/corpus-app`.

## Bake-off

```sh
bun run corpus:bakeoff -- \
--reference /path/to/reference.ttf \
--family "Arial Rounded MT Bold" \
--candidate "Inter=/path/to/Inter.ttf" \
--candidate "Nunito=/path/to/Nunito.ttf" \
--visual
```

Bake-off compares a reference against a handful of manually chosen candidates side by side, printing the same advance and feature metrics per candidate. Pass `--visual` to add an experimental rendered-glyph difference column, which needs ImageMagick 7 (`magick`) on PATH; without it, no rendering is done. It calibrates the metrics against human judgment and writes nothing to the repo.

## Visual review

```sh
bun run corpus:visual -- \
--reference /path/to/reference.ttf \
--family "Verdana" \
--candidate "Inter=/path/to/Inter.ttf" \
--candidate "Nunito=/path/to/Nunito.ttf"
```

Visual review writes a small HTML page for a known shortlist of candidates.

- `--reference` and at least one `--candidate "Label=/path"` are required.
- `--reference` and `--candidate` are regular-face shorthands.
- Use `--reference-face face=/path` and `--candidate-face "Label:face=/path"` for `regular`, `bold`, `italic`, and `boldItalic`.
- `--family` is the report heading.
- `--out` sets the output path. A `.html` path is the file; any other path is a directory that receives `review.html`. The default is `.cache/corpus-visual/review.html`.

The generated app copies the selected font files into the ignored output directory so the browser can load them locally.
Loading
Loading