Expand description
§webfont-generator
Generate webfonts (SVG, TTF, EOT, WOFF, WOFF2) from SVG icon files.
§Library usage
use webfont_generator::{GenerateWebfontsOptions, FontType};
// Async API (requires a tokio runtime)
let options = GenerateWebfontsOptions {
dest: "output".to_owned(),
files: vec!["icons/add.svg".to_owned(), "icons/remove.svg".to_owned()],
font_name: Some("my-icons".to_owned()),
types: Some(vec![FontType::Woff2, FontType::Woff]),
..Default::default()
};
let result = webfont_generator::generate(options, None).await?;
if let Some(woff2) = result.woff2_bytes() {
println!("Generated WOFF2: {} bytes", woff2.len());
}use webfont_generator::{GenerateWebfontsOptions, FontType};
// Synchronous API
let options = GenerateWebfontsOptions {
dest: "output".to_owned(),
files: vec!["icons/add.svg".to_owned()],
write_files: Some(false),
..Default::default()
};
let result = webfont_generator::generate_sync(options, None).unwrap();§CLI
Install the CLI binary with:
cargo install webfont-generator --features cliThen run:
webfont-generator --dest ./dist/fonts ./icons/§Feature flags
cli: Builds thewebfont-generatorCLI binary (addsclapdependency). Not enabled by default — usecargo install webfont-generator --features cli.napi: Enables Node.js NAPI bindings for use as a native addon.
Structs§
- Format
Options - Generate
Webfonts Options - Generate
Webfonts Result - SvgFormat
Options - TtfFormat
Options - Woff
Format Options
Enums§
Functions§
- generate
- Generate webfonts from SVG files.
- generate_
sync - Synchronous version of
generate. Spawns a tokio runtime internally.
Type Aliases§
- Rename
Fn - A glyph rename function that maps file stems to custom glyph names.