Skip to content

Render a font specimen when previewing font files#101

Merged
thalida merged 5 commits into
mainfrom
feat/issue-99-font-specimen
Jul 16, 2026
Merged

Render a font specimen when previewing font files#101
thalida merged 5 commits into
mainfrom
feat/issue-99-font-specimen

Conversation

@thalida

@thalida thalida commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Closes #99

What

Font files (.woff2/.woff/.ttf/.otf) previewed as garbage bytes. Now they render a live specimen in the face:

  • Preview — a Google-Fonts-style waterfall: uppercase / lowercase / digits, then the pangram.
  • Repertoire — a Font-Book-style grid of glyphs (printable ASCII + common Latin-1/extended + ligatures).

Preview-only: the manifest/wire model and city/utils/mediaKind.ts are untouched, per the issue's design lean.

The two real bugs found while testing

Testing against real repos surfaced that every "font" on disk was a non-font, for two different reasons — both now handled:

  1. Non-font bytes spammed the console. The old approach handed every file straight to FontFace.load(url), so the browser fetched and tried to decode garbage, logging Failed to decode / OTS parsing error (which JS can't suppress). Now the preview fetches the bytes and sniffs the signature (and detects Git LFS pointers) before touching FontFace — non-fonts get a graceful notice with zero decode attempts. The face is built from the fetched buffer (no second request) and removed from document.fonts on unmount / file change.

  2. Git LFS files were never materialized. Repos that store fonts/images/video in Git LFS (e.g. islandoftex/arara) checked out as tiny pointer stubs, since the clone was a plain git clone --filter=blob:none with no LFS step and the image had no git-lfs. This wasn't font-specific — image billboards were equally broken. Fixed by installing git-lfs in the runtime image and running git lfs pull after clone/update (guarded so non-LFS repos skip it; best-effort so an LFS outage leaves pointers in place and logs rather than failing the scan; cancels propagate; heartbeat tracks the LFS object store).

Verification

  • Frontend: 2512 tests pass; tsc / eslint / prettier clean. New tests cover _previewKind → Font, specimen render, LFS-pointer rejection (no decode attempt), and real-font parse failure.
  • Backend: 275 tests pass, 90% coverage, ruff clean. New tests cover LFS detection, pull wiring on both clone paths, best-effort failure, and cancel propagation.
  • End-to-end in a rebuilt container: git lfs pull turned arara's firasans-bold.otf from a 130-byte pointer into the real 521 KB OpenType font (OTTO), and the specimen renders.

Follow-up

Coverage-accurate glyph repertoire (true Font Book parity via font-table parsing) is scoped separately in #100.

thalida and others added 4 commits July 15, 2026 20:14
Add a Font preview kind (.woff2/.woff/.ttf/.otf) to the file preview pane.
Instead of dumping a font's raw bytes as garbage text, it renders a live
specimen in the face: a Google-Fonts-style Preview waterfall (alphabet,
digits, pangram) plus a Font-Book-style Repertoire grid of glyphs.

The bytes are fetched and sniffed before touching FontFace, so non-fonts
(a Git LFS pointer that wasn't smudged on clone, a text file with a font
name) get a graceful notice rather than making the browser log a decode
error for every attempt. The face is built from the fetched buffer (no
second request) and removed from document.fonts on unmount / file change.

Preview-only: the manifest/wire model and city mediaKind are untouched.

Closes #99

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Repos that store binaries in Git LFS (fonts, images, video) checked out
as tiny text pointer stubs, since the clone was a plain
`git clone --filter=blob:none` with no LFS step and the image had no
git-lfs. A font preview then showed a parse error and image billboards
rendered garbage, even though the files are real on the source and on
the live site.

Install git-lfs in the runtime image and run `git lfs pull` after both
the fresh-clone and the update path, guarded by `git lfs ls-files` so
non-LFS repos skip it. Best effort: an LFS fetch failure (server down,
quota, auth) leaves the pointer files in place and is logged, not raised,
so the scan still completes and previews fall back gracefully. Cancels
propagate; heartbeat tracks the LFS object store so a big pull shows
progress instead of a silent wait.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
codecity now attempts git lfs pull itself, so the old 'clone with Git LFS'
instruction no longer fits. State that the LFS content couldn't be fetched
and why, since the pull is best-effort and can leave a pointer behind.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@thalida
thalida merged commit 7227512 into main Jul 16, 2026
1 check passed
@thalida
thalida deleted the feat/issue-99-font-specimen branch July 16, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render a font specimen when previewing font files (.woff2/.woff/.ttf/.otf)

1 participant