Convert from Homebrew Formulae to Casks for font installation
Formulae can't install to ~/Library/Fonts/ due to Homebrew sandboxing. Casks have a built-in `font` artifact that handles this automatically. - Replace Formula/ with Casks/ directory - Rewrite generator to produce cask files instead of formulae - Add .ttc (TrueType Collection) support - Update all tests for cask format - Update CLI and documentation - Fonts with no installable files (TTF/OTF/TTC) are skipped Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cb1918c30f
commit
76743cdc4d
273 changed files with 2509 additions and 10048 deletions
25
CLAUDE.md
25
CLAUDE.md
|
|
@ -4,12 +4,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|||
|
||||
## What This Is
|
||||
|
||||
A Homebrew tap for custom fonts. Users `brew tap` and then `brew install font-<name>`. The repo contains font assets in `font_files/` and generated Ruby formulae in `Formula/`.
|
||||
A Homebrew tap for custom fonts. Users `brew tap` and then `brew install --cask font-<name>`. The repo contains font assets in `font_files/` and generated Ruby cask files in `Casks/`.
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
# Add or update a font (cleanup + formula generation + tests + brew audit)
|
||||
# Add or update a font (cleanup + cask generation + tests + brew audit)
|
||||
uv run add-font <path_or_name>
|
||||
uv run add-font <path_or_name> --no-test --no-audit
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ uv run pytest tests/test_font_structure.py -v
|
|||
# Run tests for a specific font
|
||||
uv run pytest tests/ -v -k "font-acrylic-hand"
|
||||
|
||||
# Regenerate all formulae (without the full add-font flow)
|
||||
# Regenerate all casks (without the full add-font flow)
|
||||
python3 .fontfoldercleanup/create_homebrew_formula.py
|
||||
|
||||
# Reorganize font folders only
|
||||
|
|
@ -32,22 +32,23 @@ python3 .fontfoldercleanup/cleanup_font_folders.py --path font_files
|
|||
## Architecture
|
||||
|
||||
- **`font_files/font-<name>/`** — Each font has exactly 4 subdirs: `ttf/`, `otf/`, `web/`, `other_files/`. No other top-level files allowed.
|
||||
- **`Formula/font-<name>.rb`** — Generated Ruby formulae. **Never edit by hand.** Edits go in `.fontfoldercleanup/create_homebrew_formula.py`.
|
||||
- **`tap_cli/main.py`** — The `add-font` CLI entry point. Copies font to `font_files/`, runs cleanup script, runs formula generator, then runs tests and `brew audit`.
|
||||
- **`Casks/font-<name>.rb`** — Generated Ruby cask files. **Never edit by hand.** Edits go in `.fontfoldercleanup/create_homebrew_formula.py`.
|
||||
- **`tap_cli/main.py`** — The `add-font` CLI entry point. Copies font to `font_files/`, runs cleanup script, runs cask generator, then runs tests and `brew audit`.
|
||||
- **`.fontfoldercleanup/cleanup_font_folders.py`** — Sorts loose font files into `ttf/`, `otf/`, `web/`, `other_files/` subdirs.
|
||||
- **`.fontfoldercleanup/create_homebrew_formula.py`** — Scans `font_files/font-*` and writes one `.rb` per font. Contains `HomebrewFormulaGenerator` class and `formula_name_to_class()` for Ruby PascalCase conversion.
|
||||
- **`tests/`** — Parametrized pytest suite. Tests validate: folder structure, formula existence, formula content (paths, class name), no orphan formulae, no duplicates.
|
||||
- **`.fontfoldercleanup/create_homebrew_formula.py`** — Scans `font_files/font-*` and writes one cask `.rb` per font in `Casks/`.
|
||||
- **`tests/`** — Parametrized pytest suite. Tests validate: folder structure, cask existence, cask content (paths, identifier), no orphan casks, no duplicates.
|
||||
- **`To Sort/`** — Staging area for new downloads not yet processed.
|
||||
|
||||
## Formula Naming Convention
|
||||
## Cask Naming Convention
|
||||
|
||||
`font-<name>` → Ruby class `Font<PascalCase>`. Split on hyphens/underscores, capitalize each part:
|
||||
- `font-acrylic-hand` → `FontAcrylicHand`
|
||||
- `font-graham_hand` → `FontGrahamHand`
|
||||
Cask files use kebab-case identifiers matching the font folder name: `font-<name>`.
|
||||
- `font-acrylic-hand` → `cask "font-acrylic-hand" do`
|
||||
|
||||
Fonts are installed to `~/Library/Fonts/` automatically via the `font` artifact.
|
||||
|
||||
## Key Constraints
|
||||
|
||||
- Python 3, standard library only (pathlib, shutil, argparse, re). pytest is the sole dependency.
|
||||
- Formulae download from `http://clancy.genet-godzilla.ts.net:8085/Fonts/homebrew-fonts/archive/main.tar.gz` and expect the archive to unpack as `homebrew-fonts/`.
|
||||
- Casks download from `http://clancy.genet-godzilla.ts.net:8085/Fonts/homebrew-fonts/archive/main.tar.gz` and expect the archive to unpack as `homebrew-fonts/`.
|
||||
- CI runs `uv run pytest` on push/PR to main, plus `brew audit` on macOS (non-blocking).
|
||||
- `PROJECT.md` is the canonical project description. When updating project rules, update `PROJECT.md` first, then sync `.cursorrules`, `.github/copilot-instructions.md`, and `.claude/skills/project-context/SKILL.md`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue