Skip to main content

TextMeasurer

Trait TextMeasurer 

Source
pub trait TextMeasurer: 'static {
Show 17 methods // Required methods fn measure(&self, text: &AnnotatedString, style: &TextStyle) -> TextMetrics; fn get_offset_for_position( &self, text: &AnnotatedString, style: &TextStyle, x: f32, y: f32, ) -> usize; fn get_cursor_x_for_offset( &self, text: &AnnotatedString, style: &TextStyle, offset: usize, ) -> f32; fn layout( &self, text: &AnnotatedString, style: &TextStyle, ) -> TextLayoutResult; // Provided methods fn measure_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, ) -> TextMetrics { ... } fn measure_subsequence( &self, text: &AnnotatedString, range: Range<usize>, style: &TextStyle, ) -> TextMetrics { ... } fn measure_subsequence_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, range: Range<usize>, style: &TextStyle, ) -> TextMetrics { ... } fn measure_line_prefix_widths( &self, text: &AnnotatedString, line_range: Range<usize>, style: &TextStyle, ) -> Option<TextLinePrefixWidths> { ... } fn measure_line_width( &self, text: &AnnotatedString, line_range: Range<usize>, style: &TextStyle, ) -> Option<f32> { ... } fn line_height(&self, text: &AnnotatedString, style: &TextStyle) -> f32 { ... } fn line_height_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, ) -> f32 { ... } fn choose_auto_hyphen_break( &self, _line: &str, _style: &TextStyle, _segment_start_char: usize, _measured_break_char: usize, ) -> Option<usize> { ... } fn measure_with_options( &self, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> TextMetrics { ... } fn measure_with_options_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> TextMetrics { ... } fn prepare_with_options( &self, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> PreparedTextLayout { ... } fn prepare_with_options_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> PreparedTextLayout { ... } fn prepare_with_options_fallback( &self, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> PreparedTextLayout { ... }
}
Expand description

Re-export the UI crate so applications can depend on a single crate.

Required Methods§

Source

fn measure(&self, text: &AnnotatedString, style: &TextStyle) -> TextMetrics

Source

fn get_offset_for_position( &self, text: &AnnotatedString, style: &TextStyle, x: f32, y: f32, ) -> usize

Source

fn get_cursor_x_for_offset( &self, text: &AnnotatedString, style: &TextStyle, offset: usize, ) -> f32

Source

fn layout(&self, text: &AnnotatedString, style: &TextStyle) -> TextLayoutResult

Provided Methods§

Source

fn measure_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, ) -> TextMetrics

Source

fn measure_subsequence( &self, text: &AnnotatedString, range: Range<usize>, style: &TextStyle, ) -> TextMetrics

Source

fn measure_subsequence_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, range: Range<usize>, style: &TextStyle, ) -> TextMetrics

Source

fn measure_line_prefix_widths( &self, text: &AnnotatedString, line_range: Range<usize>, style: &TextStyle, ) -> Option<TextLinePrefixWidths>

Source

fn measure_line_width( &self, text: &AnnotatedString, line_range: Range<usize>, style: &TextStyle, ) -> Option<f32>

Source

fn line_height(&self, text: &AnnotatedString, style: &TextStyle) -> f32

Source

fn line_height_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, ) -> f32

Source

fn choose_auto_hyphen_break( &self, _line: &str, _style: &TextStyle, _segment_start_char: usize, _measured_break_char: usize, ) -> Option<usize>

Returns an alternate break boundary for Hyphens::Auto when a greedy break split lands in the middle of a word.

segment_start_char and measured_break_char are character-boundary indices in line (not byte offsets). Return None to delegate to fallback behavior.

Source

fn measure_with_options( &self, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> TextMetrics

Source

fn measure_with_options_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> TextMetrics

Source

fn prepare_with_options( &self, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> PreparedTextLayout

Source

fn prepare_with_options_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> PreparedTextLayout

Source

fn prepare_with_options_fallback( &self, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> PreparedTextLayout

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TextMeasurer for SoftwareTextMeasurer

Source§

fn measure(&self, text: &AnnotatedString, style: &TextStyle) -> TextMetrics

Source§

fn measure_subsequence( &self, text: &AnnotatedString, range: Range<usize>, style: &TextStyle, ) -> TextMetrics

Source§

fn measure_line_prefix_widths( &self, text: &AnnotatedString, line_range: Range<usize>, style: &TextStyle, ) -> Option<TextLinePrefixWidths>

Source§

fn measure_line_width( &self, text: &AnnotatedString, line_range: Range<usize>, style: &TextStyle, ) -> Option<f32>

Source§

fn line_height(&self, text: &AnnotatedString, style: &TextStyle) -> f32

Source§

fn get_offset_for_position( &self, text: &AnnotatedString, style: &TextStyle, x: f32, y: f32, ) -> usize

Source§

fn get_cursor_x_for_offset( &self, text: &AnnotatedString, style: &TextStyle, offset: usize, ) -> f32

Source§

fn layout(&self, text: &AnnotatedString, style: &TextStyle) -> TextLayoutResult

Source§

fn choose_auto_hyphen_break( &self, line: &str, style: &TextStyle, segment_start_char: usize, measured_break_char: usize, ) -> Option<usize>

Implementors§