flash-font-injector
flash-font-injector is a low-level Rust library for temporarily loading system fonts. It provides a reliable mechanism to inject physical font files (e.g., .ttf, .otf) into the Windows system font table, making them available to local processes without permanently installing them.
Used by flash-font.
Features
- Temporary Injection: Safely loads fonts using native Windows API (
AddFontResourceExW). - Parallel Loading: Supports mass loading and unloading of fonts concurrently using
rayon. - RAII Unloading: Provides a
FontManagerthat can optionally unload all loaded fonts automatically when it is dropped, preventing system font table pollution.
Usage
use ;
use Utf8PathBuf;
// By default, FontManager keeps fonts loaded after getting dropped.
// We can configure it to clean up the fonts automatically:
let config = FontManagerConfig ;
let mut manager = new;
// Load a single font
manager.load.unwrap;
// Load multiple fonts in parallel
let paths = vec!;
manager.load_all.unwrap;
// Fonts are unloaded here because keep_loaded_fonts is false
License
MIT OR Apache-2.0