blinc_text
Part of the Blinc UI Framework
This crate is a component of Blinc, a GPU-accelerated UI framework for Rust. For full documentation and guides, visit the Blinc documentation.
High-quality text rendering for Blinc UI.
Overview
blinc_text provides comprehensive text rendering capabilities including font loading, text shaping, glyph rasterization, and layout.
Features
- Font Loading: TTF/OTF support via ttf-parser
- Text Shaping: Complex script support via rustybuzz (HarfBuzz)
- Glyph Rasterization: High-quality rendering via swash
- Glyph Atlases: Efficient GPU texture caching
- Text Layout: Line breaking, word wrapping, alignment
- Emoji Support: Full color emoji rendering
- Memory Efficient: Global shared font registry
Quick Start
use ;
// Load fonts
let registry = global_font_registry;
registry.load_font_file?;
// Create renderer
let renderer = new;
// Prepare text for rendering
let prepared = renderer.prepare;
// Get glyph positions for GPU rendering
for glyph in prepared.glyphs
Font Registry
use global_font_registry;
let registry = global_font_registry;
// Load single font
registry.load_font_file?;
// Load directory
registry.load_font_directory?;
// Load system fonts
for path in system_font_paths
Text Shaping
use ;
let shaper = new;
let shaped: ShapedText = shaper.shape;
// Shaped text contains positioned glyphs
for glyph in shaped.glyphs
Text Layout
use ;
let engine = new;
let layout = engine.layout;
// Get line positions
for line in layout.lines
Glyph Atlases
use GlyphAtlas;
// Create atlas for GPU rendering
let atlas = new;
// Add glyphs
let uv = atlas.add_glyph?;
// Get texture for GPU
let texture = atlas.texture;
Emoji Support
use ;
// Check for emoji
assert!;
assert!;
// Render emoji
let renderer = new;
let image = renderer.render_emoji?;
Architecture
blinc_text
├── font.rs # Font loading and parsing
├── shaper.rs # Text shaping (rustybuzz)
├── rasterizer.rs # Glyph rasterization (swash)
├── atlas.rs # Glyph atlas management
├── layout.rs # Text layout engine
├── emoji.rs # Emoji rendering
└── registry.rs # Global font registry
License
MIT OR Apache-2.0