Skip to content

fix(nix): give ImageMagick a pinned font for OCR test fixtures - #1054

Merged
cpcloud merged 1 commit into
mainfrom
fix-dev-shell-fonts
Oct 23, 2026
Merged

cpcloud merged 1 commit into
mainfrom
fix-dev-shell-fonts

Conversation

@cpcloud

@cpcloud cpcloud commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • On a fresh checkout, direnv reload fails with exit status 1. The dev shell hook draws text into two OCR test images, and ImageMagick finds no font because the shell has no fontconfig setup. nix run '.#gen-testdata' fails the same way.
  • The dev shell and the two image gen-* packages now give ImageMagick a Hack Nerd Font file through MICASA_FIXTURE_FONT. Hack is already in the flake for VHS recordings. The hook and the apps now render the same pixels on any host.
  • CI runs the scripts without Nix, so they pass -font only when that variable is set.
  • With the fixtures present, the image OCR tests now run locally. Under nix develop -c on macOS they fail: nix develop sets TMPDIR under /tmp, and tesseract can't open its input file there. Under direnv they pass. The bug predates this PR; the tests used to skip because the fixtures were missing.

Reproduce on main

  1. rm -r internal/extract/testdata
  2. direnv exec . true
  3. ImageMagick prints Fontconfig error: Cannot load default config file and unable to read font, and direnv exits 1.

🤖 Generated with Claude Code

On a fresh checkout, or after `git clean -xdf`, the dev shell hook
generates the OCR test fixtures. ImageMagick needs a font to draw their
text. The dev shell has no fontconfig configuration, so ImageMagick
found no font and exited non-zero. That made `direnv reload` fail, and
new worktrees could not load the dev shell. `nix run '.#gen-testdata'`
failed the same way.

The dev shell and the gen-invoice-png and gen-sample-text-png packages
now pass a Hack Nerd Font file to ImageMagick. Hack is already in the
flake for VHS recordings. A file path skips fontconfig, and the
fixtures no longer depend on whatever fonts the host has. The shell hook
and the `nix run` apps now render pixel-identical images.

CI runs the same scripts without Nix and uses ImageMagick's default
font, so the scripts pass the font only when MICASA_FIXTURE_FONT is set.

The OCR tests read these fixtures. Before this fix they skipped locally
because the fixtures were missing.

Generated with Claude Code (claude-opus-5-5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cpcloud cpcloud added bug Something isn't working nix Nix packaging and build labels Oct 23, 2026
@cpcloud
cpcloud enabled auto-merge (squash) October 23, 2026 14:51
@cpcloud
cpcloud merged commit 6b6b4be into main Oct 23, 2026
38 of 43 checks passed
@cpcloud
cpcloud deleted the fix-dev-shell-fonts branch October 23, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working nix Nix packaging and build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant