Render a font specimen when previewing font files#101
Merged
Conversation
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>
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.
Closes #99
What
Font files (
.woff2/.woff/.ttf/.otf) previewed as garbage bytes. Now they render a live specimen in the face:Preview-only: the manifest/wire model and
city/utils/mediaKind.tsare 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:
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, loggingFailed 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 touchingFontFace— non-fonts get a graceful notice with zero decode attempts. The face is built from the fetched buffer (no second request) and removed fromdocument.fontson unmount / file change.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 plaingit clone --filter=blob:nonewith no LFS step and the image had no git-lfs. This wasn't font-specific — image billboards were equally broken. Fixed by installinggit-lfsin the runtime image and runninggit lfs pullafter 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
_previewKind→ Font, specimen render, LFS-pointer rejection (no decode attempt), and real-font parse failure.git lfs pullturned arara'sfirasans-bold.otffrom 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.