Expand description
Deterministic fallback path for shaped text rendering.
When the shaping engine is unavailable (no font data, feature disabled, or runtime budget exceeded), this module provides a guaranteed fallback that preserves:
- Semantic correctness: all grapheme clusters are rendered.
- Interaction stability: cursor, selection, and copy produce identical results regardless of whether shaping was used.
- Determinism: the same input always produces the same output.
§Fallback strategy
The ShapingFallback struct wraps an optional shaper and transparently
degrades when shaping is unavailable or fails:
RustybuzzShaper available → use shaped rendering
↓ (failure or unavailable)
NoopShaper → terminal/monospace rendering (always succeeds)Both paths produce a ShapedLineLayout with identical interface,
ensuring downstream code (cursor navigation, selection, copy) works
without branching on which path was taken.
§Example
use ftui_text::shaping_fallback::{ShapingFallback, FallbackEvent};
use ftui_text::shaping::NoopShaper;
use ftui_text::script_segmentation::{Script, RunDirection};
// Create a fallback that always uses NoopShaper (terminal mode).
let fallback = ShapingFallback::terminal();
let (layout, event) = fallback.shape_line("Hello!", Script::Latin, RunDirection::Ltr);
assert_eq!(layout.total_cells(), 6);
assert_eq!(event, FallbackEvent::NoopUsed);Structs§
- Fallback
Stats - Accumulated fallback statistics for monitoring quality degradation.
- Shaping
Fallback - Transparent shaping with guaranteed fallback.
Enums§
- Fallback
Event - Diagnostic event describing which path was taken.