Protextinator
Protextinator is a text editing and rendering library for Rust, built on top of cosmic_text. It provides a simpler API while adding features like vertical alignment, scroll position management, and text selection.
Note: This library is still a work in progress. APIs may change.
Features
- Vertical text alignment
- Text buffer size measurement
- Scroll position management with absolute coordinates
- Simple font loading from files or embedded bytes
- Text state collection with optional usage tracking
- Custom metadata for text states
- Text selection and editing
- Efficient text buffer caching
- Word wrapping and text styling
- Optional serialization support
Installation
Add this to your Cargo.toml:
[]
= "0.5.0"
With serialization:
[]
= { = "0.1.0", = ["serialization"] }
Quick Start
use ;
use ;
use TextStyle;
// Create a text manager
let mut text_manager = new;
// Create a text state
let id = new;
let text = "Hello, world!";
text_manager.create_state;
// Add fonts
let font_sources: = vec!;
text_manager.load_fonts;
// Alternatively, you can load fonts from bytes if you want to embed them into the binary
// or download them at runtime as bytes
let byte_sources: = vec!;
text_manager.load_fonts_from_bytes;
// Optional: Marks the beginning of a frame so that you can track which text states are accessed
text_manager.start_frame;
// Configure the text area size and style
if let Some = text_manager.text_states.get_mut
let mut remove_ids = vec!;
// Optional: going to remove all states that were not accessed during the current frame
text_manager.end_frame;
For a complete example, see the examples directory.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.