How hasanzakeri/harfrust-python works
harfrust-python exposes HarfRust text shaping to Python through a PyO3 extension, with both a one-shot CLI-compatible API and a configurable object API. The object workflow configures Unicode text and segment properties, loads/configures a font and shaping options, shapes the buffer, then provides positioned glyph data and serialization. Configuration types support script, direction, language, features, and variable-font variations. Edges reflect explicit calls in the sampled Rust source; the HarfRust engine and CLI helper are dependency APIs rather than repository modules.
Main entry points: font.rs Font and shaper · lib.rs PyO3 extension · buffer.rs Text buffer · shape.rs One-shot CLI API
Components 10
Python API
- Public package
python/pyharfrust/__init__.py - PyO3 extension
src/lib.rs
Shaping Workflow
- One-shot CLI API
src/shape.rs - Text buffer
src/buffer.rs - Font and shaper
src/font.rs - Glyph results
src/glyph.rs
Configuration
- Configuration types
src/types.rs
Other components
- Python caller
- HarfRust engine
- Font file
Connections 18
- Python caller → Public package: imports
python/pyharfrust/__init__.py - Public package → PyO3 extension: re-exports
python/pyharfrust/__init__.py - PyO3 extension → One-shot CLI API: registers
src/lib.rs - PyO3 extension → Text buffer: registers
src/lib.rs - PyO3 extension → Font and shaper: registers
src/lib.rs - PyO3 extension → Glyph results: registers
src/lib.rs - PyO3 extension → Configuration types: registers
src/lib.rs - Python caller → One-shot CLI API: calls
README.md - Python caller → Text buffer: builds text
README.md - Python caller → Font and shaper: configures font
README.md - Text buffer → Configuration types: uses properties
src/buffer.rs - Font and shaper → Text buffer: consumes buffer
src/font.rs - Font and shaper → Configuration types: parses options
src/font.rs - Font and shaper → Glyph results: wraps output
src/font.rs - Font and shaper → Font file: reads
src/font.rs - Font and shaper → HarfRust engine: shapes with
src/font.rs - Glyph results → Font and shaper: serializes with
src/glyph.rs - One-shot CLI API → HarfRust engine: delegates shaping
src/shape.rs