Repository navigation
fix(nix): give ImageMagick a pinned font for OCR test fixtures - #1054
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
direnv reloadfails 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.gen-*packages now give ImageMagick a Hack Nerd Font file throughMICASA_FIXTURE_FONT. Hack is already in the flake for VHS recordings. The hook and the apps now render the same pixels on any host.-fontonly when that variable is set.nix develop -con macOS they fail:nix developsetsTMPDIRunder/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
rm -r internal/extract/testdatadirenv exec . trueFontconfig error: Cannot load default config fileandunable to read font, and direnv exits 1.🤖 Generated with Claude Code