Skip to content

feat(fonts): Google Fonts fetching with local cache#57

Merged
LeadcodeDev merged 1 commit into
mainfrom
feat/google-fonts
Jul 18, 2026
Merged

feat(fonts): Google Fonts fetching with local cache#57
LeadcodeDev merged 1 commit into
mainfrom
feat/google-fonts

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

Closes #50.

Goal: declare fonts by family name — fonts: [{"family": "Inter", "source": "google", "weights": [400, 700]}], and <font family="Inter" source="google" weights="400,700"> in the HTML dialect.

  • css2 endpoint with a non-browser UA → TTF URLs parsed with a hand-rolled scanner (no new dependencies; ureq was already present for icons)
  • Disk cache ~/.cache/rustmotion/fonts/<family-slug>-<weight>.ttf (%LOCALAPPDATA% on Windows); cache hits never touch the network — proven by tests with injected cache dirs and pre-placed files
  • Offline without cache → error naming the family, the URL tried, and the exact path where to drop a TTF manually; misspelled family (CSS without TTF urls) → dedicated error
  • FontEntry.path becomes Option with strict validation (missing both / both set → dedicated errors); existing {path, family} entries unchanged
  • Integration note: the agent's clippy run missed --all-targets (5 real warnings on the branch); fixed during review — the verification gap, not the feature.

Tests: 22 new (URL building, CSS parsing, slugs, cache hits ×2, entry resolution ×4, HTML transpilation ×4, network test behind #[ignore]). 272 total, all green.

Verify: cargo test --workspace → 272 passed ✓ · cargo fmt --check ✓ · clippy 0 warnings ✓

fonts: [{family: "Inter", source: "google", weights: [400,700]}]
(and <font family=.. source=google weights=..> in the HTML dialect)
downloads TTFs via the css2 endpoint with a non-browser UA and caches
them in ~/.cache/rustmotion/fonts (LOCALAPPDATA on Windows). Cache
hits never touch the network (tested with injected cache dirs); the
offline error names the family, the URL tried and the exact cache
path for manual placement. path stays required for local entries
(path+source conflict and missing-both are dedicated errors); existing
{path, family} entries deserialize and load unchanged. No new
dependencies (ureq was already there for icons). Clippy warnings from
the agent pass fixed during integration review.
@LeadcodeDev
LeadcodeDev merged commit c191df4 into main Jul 18, 2026
@LeadcodeDev
LeadcodeDev deleted the feat/google-fonts branch July 18, 2026 23:25
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.

feat(fonts): Google Fonts fetching with local cache

1 participant