| Crates.io | titanf |
| lib.rs | titanf |
| version | 2.3.2 |
| created_at | 2025-10-16 03:44:08.908907+00 |
| updated_at | 2025-12-09 04:09:52.038035+00 |
| description | Fast, safe, no_std font rasterizer written in pure Rust |
| homepage | https://github.com/Hoteira/titanf |
| repository | https://github.com/Hoteira/titan-f |
| max_upload_size | |
| id | 1885345 |
| size | 129,662 |
High-Performance, Zero-Dependency TrueType Font Rasterizer
Pure Rust • SIMD Accelerated • Memory Safe • Bare-Metal Ready
TiTanF is a production-grade TrueType font rasterizer implemented entirely in Rust without any external dependencies (libc, freetype, etc.). It was engineered to explore high-performance vector graphics rendering techniques suitable for embedded systems and OS development.
The library features a hand-written parser for the TrueType format, a robust geometry processing pipeline, and a custom anti-aliased rasterizer accelerated by SIMD instructions (SSE2 on x86_64, NEON on AArch64).
x86_64 (SSE2) and aarch64 (NEON) to optimize the pixel coverage accumulation stage.no_std compatible (requires alloc), making it ideal for kernels, bootloaders, and embedded graphical interfaces.unsafe limited strictly to SIMD optimizations.glyf, cmap (Format 0, 4, 6, 12), kern, hmtx, etc.).The rendering pipeline is architected into three distinct stages to maximize modularity and performance:
src/tables):
Raw binary data is parsed into strongly-typed Rust structures. Complex tables like glyf (glyph data) are lazy-loaded to minimize initial memory footprint.src/geometry):
src/rasterizer):
Add this to your Cargo.toml:
[dependencies]
titanf = "2.1.0"
Rendering a Character:
use titanf::TrueTypeFont;
fn main() {
// 1. Load font bytes (e.g., from a file or include_bytes!)
let font_data = include_bytes!("../assets/Roboto-Regular.ttf");
let mut font = TrueTypeFont::load_font(font_data).expect("Failed to parse font");
// 2. Configure render settings
font.set_dpi(72.0);
// 3. Rasterize 'A' at 24px
// Returns metrics and a linear alpha buffer (Vec<u8>)
let (metrics, bitmap) = font.get_char::<true>('A', 24.0);
println!("Rendered 'A': {}x{} pixels", metrics.width, metrics.height);
}
Benchmarks performed on an AMD Ryzen 9 5900X rendering 1,000 characters (Mixed CJK & Latin).
| Font Size | TiTanF | RustType | ab_glyph | Fontdue |
|---|---|---|---|---|
| 12px | 18.4 ms | 18.6 ms | 16.9 ms | 4.8 ms |
| 72px | 51.5 ms | 54.8 ms | 51.9 ms | 24.0 ms |
| 120px | 86.4 ms | 99.5 ms | 98.0 ms | 51.2 ms |
| 250px | 244.0 ms | 304.1 ms | 296.0 ms | 165.2 ms |
TiTanF scales significantly better than other pure-Rust alternatives at larger sizes due to its O(1) memory allocation strategy and SIMD optimizations.
Distributed under the MIT license.