fontsource-downloader
A library to download (and cache) fonts with fontsource REST API.
Library Features
- Download a batch of fonts per family (based on the given query).
- Asynchronous downloads with true parallelism.
- Generate CSS
@font-facerules. Both CDN URLs and self-hosting (relative path) URLs are supported. Self-hosted font files can be optionally copied from cache to a given destination directory. - Caching enabled (with option to customize cache root dir) for both metadata and font files.
- Minimal debug logs (when enabled).
Rust consumers get to choose their desired TLS backend. Only the required features of the reqwest crate are enabled.
Examples
Python
# the only supported async runtime in python
# configure logging before importing this library
=
=
: = await
# do what you want with the cached font files ...
Rust
use PathBuf;
use ;
let client = new.unwrap;
let query: FontQuery = new
.with_weight
.build;
let font_files: = client
.download_font
.await
.unwrap;
// do what you want with the cached font files ...