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§
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
Sourcefn choose_auto_hyphen_break(
&self,
_line: &str,
_style: &TextStyle,
_segment_start_char: usize,
_measured_break_char: usize,
) -> Option<usize>
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.
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
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".