pub trait TextMeasurer: 'static {
// Required methods
fn measure(&self, text: &str) -> TextMetrics;
fn get_offset_for_position(&self, text: &str, x: f32, y: f32) -> usize;
fn get_cursor_x_for_offset(&self, text: &str, offset: usize) -> f32;
fn layout(&self, text: &str) -> TextLayoutResult;
}Required Methods§
fn measure(&self, text: &str) -> TextMetrics
Sourcefn get_offset_for_position(&self, text: &str, x: f32, y: f32) -> usize
fn get_offset_for_position(&self, text: &str, x: f32, y: f32) -> usize
Returns byte offset in text for given x position. Used for cursor positioning on click.
The y parameter is for future multiline support.
Sourcefn get_cursor_x_for_offset(&self, text: &str, offset: usize) -> f32
fn get_cursor_x_for_offset(&self, text: &str, offset: usize) -> f32
Returns x position for given byte offset. Used for cursor rendering and selection geometry.
Sourcefn layout(&self, text: &str) -> TextLayoutResult
fn layout(&self, text: &str) -> TextLayoutResult
Computes full text layout with cached glyph positions. Returns TextLayoutResult for O(1) position lookups.