https://github.com/bearcove/fontcull
Font subsetting for Rust (C++ present only for woff2 compression)
https://github.com/bearcove/fontcull
fonts subsetting ttf woff2
Last synced: 3 months ago
JSON representation
Font subsetting for Rust (C++ present only for woff2 compression)
- Host: GitHub
- URL: https://github.com/bearcove/fontcull
- Owner: bearcove
- License: mit
- Created: 2025-11-28T12:47:46.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-12-03T15:23:39.000Z (5 months ago)
- Last Synced: 2026-01-13T11:20:24.255Z (3 months ago)
- Topics: fonts, subsetting, ttf, woff2
- Language: Rust
- Homepage:
- Size: 8.59 MB
- Stars: 34
- Watchers: 0
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# fontcull
[](https://crates.io/crates/fontcull)
[](https://docs.rs/fontcull)
[](LICENSE)
Pure Rust font subsetting library powered by [klippa](https://github.com/googlefonts/fontations).
## Library usage
```rust
use fontcull::{subset_font_to_woff2, decompress_font};
use std::collections::HashSet;
// Subset a font to only include specific characters
let font_data = std::fs::read("font.ttf").unwrap();
let chars: HashSet = "Hello World".chars().collect();
let woff2 = subset_font_to_woff2(&font_data, &chars).unwrap();
std::fs::write("font-subset.woff2", woff2).unwrap();
// Can also decompress WOFF/WOFF2 to TTF
let woff2_data = std::fs::read("font.woff2").unwrap();
let ttf_data = decompress_font(&woff2_data).unwrap();
```
### Features
- `static-analysis`: Static HTML/CSS parsing for font usage detection
## CLI
The `fontcull-cli` crate provides a command-line tool that:
1. Opens URLs in a headless browser (via chromiumoxide)
2. Extracts all glyphs/characters used on the page (including `::before`/`::after` pseudo-elements)
3. Optionally spiders the site to find more pages
4. Subsets font files to only include the characters actually used
### Install
```bash
cargo install fontcull-cli
```
Requires Chrome/Chromium installed (uses your system browser, no specific version needed).
### Usage
```bash
# Just get the unicode range of characters used
fontcull https://example.com
# Subset fonts based on page content
fontcull https://example.com --subset=fonts/*.ttf
# Spider multiple pages
fontcull https://example.com --spider-limit=10 --subset=fonts/*.ttf
# Filter by font family
fontcull https://example.com --subset=fonts/*.ttf --family="My Font"
# Add extra characters to always include
fontcull https://example.com --subset=fonts/*.ttf --whitelist="0123456789"
```
## Sponsors
Thanks to all individual sponsors:


...along with corporate sponsors:


...without whom this work could not exist.