Expand description
§typf-core: The Engine Room
Six stages from text to pixels. No magic, just engineering.
Text enters as Unicode chaos, exits as perfect pixels. This crate is the engine room that makes text rendering work when half your characters are Arabic and the other half are emoji.
§The Pipeline: Brutal Simplicity
Every text walks this path, no shortcuts:
- Input Parsing - Raw strings → structured data. We don’t guess encoding.
- Unicode Processing - Bidi, scripts, segmentation. The hard stuff.
- Font Selection - Right font for each character, period. Fallback that actually works.
- Shaping - Characters → positioned glyphs. Where HarfBuzz lives.
- Rendering - Glyphs → pixels/vectors. SIMD or die.
- Export - Your format, ready to ship.
§Build Your First Pipeline
use typf_core::{Pipeline, RenderParams, ShapingParams};
use std::sync::Arc;
let pipeline = Pipeline::builder()
.shaper(Arc::new(MyShaper))
.renderer(Arc::new(MyRenderer))
.exporter(Arc::new(MyExporter))
.build()?;
let font = load_font();
let output = pipeline.process(
"Hello, World!",
font,
&ShapingParams::default(),
&RenderParams::default(),
)?;§The Traits That Power Everything
Want to add your own backend? Implement one of these:
Stage- The foundation every pipeline component builds upon.Shaper- Where characters become glyphs.Renderer- Where glyphs become images.Exporter- Where images become files.traits::FontRef- Your window into font data.
Data flows through the types in types - these structures carry
the results from one stage to the next.
Re-exports§
pub use context::PipelineContext;pub use error::Result;pub use error::TypfError;pub use pipeline::Pipeline;pub use pipeline::PipelineBuilder;pub use traits::Exporter;pub use traits::Renderer;pub use traits::Shaper;pub use traits::Stage;
Modules§
- cache
- Scan-resistant caching with TinyLFU and byte-weighted eviction
- cache_
config - Global cache configuration
- context
- The traveling container that carries data through pipeline stages
- error
- When things go wrong in the pipeline
- ffi
- C-ABI compatible types for FFI consumers.
- glyph_
cache - Backend-neutral glyph/render cache with byte-weighted eviction
- linra
- Linra rendering: shape and render in a single pass
- pipeline
- The engine that drives text through six stages to become images
- shaping_
cache - Backend-agnostic shaping cache
- traits
- The contracts that bind every backend together
- types
- The data structures that power the pipeline.
Structs§
- Color
- Simple RGBA color that works everywhere
- Glyph
Source Preference - Preference ordering and deny list for glyph sources
- Render
Params - How rendering should look
- Shaping
Params - How shaping should behave
Enums§
- Glyph
Source - Which glyph data sources are allowed and in what order
- Render
Mode - Target output for rendering operations
Constants§
- DEFAULT_
MAX_ BITMAP_ HEIGHT - Default maximum bitmap height: 16k pixels
- DEFAULT_
MAX_ BITMAP_ PIXELS - Default maximum total bitmap pixels: 1 Gpix
- DEFAULT_
MAX_ BITMAP_ WIDTH - Default maximum bitmap dimension (width): 16,777,216 pixels (16M)
- MAX_
FONT_ SIZE - Maximum font size in pixels to prevent DoS attacks.
- MAX_
GLYPH_ COUNT - Maximum number of glyphs to render in a single operation.
Functions§
- get_
max_ bitmap_ height - Get max bitmap height from environment or use default (16384).
- get_
max_ bitmap_ pixels - Get max bitmap pixels from environment or use default (1 Gpix).
- get_
max_ bitmap_ width - Get max bitmap width from environment or use default (16,777,216).
- validate_
glyph_ count - Validate glyph count against security limits