Expand description
§Icon to Image
A high-performance library for rendering Font Awesome icons to images.
This library provides fast icon rendering using the ab_glyph rasterizer
with support for supersampling antialiasing, customizable colors and sizes,
and output to PNG and WebP formats.
§Features
- Embedded Font Awesome assets (no external files needed)
- Fast glyph rasterization with
ab_glyph - Supersampling for high-quality antialiased output
- PNG and WebP output formats
- Customizable icon and background colors (hex and RGB)
- Flexible positioning with anchors and offsets
- Separate icon and canvas sizes
- Python bindings via PyO3
§Example (Rust)
use icon_to_image::{IconRenderer, RenderConfig, Color, ImageFormat, encode};
// Use embedded assets (recommended) - no external files needed
let renderer = IconRenderer::new()?;
// Or load from a custom path if you have different font versions:
// let renderer = IconRenderer::from_path("./assets")?;
let config = RenderConfig::new()
.canvas_size(1024, 1024)
.icon_size(800)
.icon_color(Color::from_hex("#FF5733")?)
.background_color(Color::transparent());
let (width, height, pixels) = renderer.render("heart", &config)?;
let png_data = encode(&pixels, width, height, ImageFormat::Png)?;
std::fs::write("heart.png", png_data)?;Modules§
- embedded
- Embedded Font Awesome assets.
Structs§
- Color
- RGBA color representation with values from 0-255.
- CssParser
- Parser for Font Awesome CSS files.
- Icon
Mapping - Icon mapping containing the Unicode codepoint and font style.
- Icon
Renderer - Icon font renderer that loads fonts and renders icons to images.
- Render
Config - Configuration for rendering an icon.
Enums§
- Font
Style - Represents the font style/weight for an icon.
- Horizontal
Anchor - Horizontal anchor position for icon placement.
- Icon
Font Error - Errors that can occur during icon font rendering operations.
- Image
Format - Image output format.
- Vertical
Anchor - Vertical anchor position for icon placement.
Functions§
- encode
- Encode pixels to the specified format.
- encode_
png - Encode RGBA pixels to PNG format.
- encode_
webp - Encode RGBA pixels to WebP format.
- save_
to_ file - Save pixels to a file with format determined by extension.
Type Aliases§
- Result
- Result type alias for operations that can fail with
IconFontError.