Expand description
Google Fonts download and disk-cache helpers.
§Cache layout
~/.cache/rustmotion/fonts/
inter-400.ttf
inter-700.ttf
jetbrains-mono-400.ttfFile names are derived from the family name by lower-casing and replacing
spaces with hyphens: "JetBrains Mono" → "jetbrains-mono".
§Network protocol
GET https://fonts.googleapis.com/css2?family=<Family+Name>:wght@<w1>;<w2>withureq’s default (non-browser) User-Agent. Google returns a CSS stylesheet containingurl(…)entries pointing at.ttffiles.- We extract every
url(…)from the CSS and download each TTF.
No new crate dependencies are introduced; ureq (v3) is already in
rustmotion-core.
Functions§
- build_
css2_ url - Build the Google Fonts CSS2 API URL.
- family_
slug - Convert a font family name to a filesystem-safe slug.
- font_
cache_ dir - Returns the platform-appropriate font cache directory.
- parse_
ttf_ urls - Extract all
url(…)values that end with.ttffrom a Google Fonts CSS response. No regex crate is used — we findurl(markers and extract the inner content. - resolve_
google_ font - Ensure TTFs for
family+weightsare present on disk (download if needed) and return their paths.