pub trait TextMeasurer: Send + Sync {
// Required method
fn measure(
&self,
text: &str,
style: &TextStyle<&str>,
max_width: Option<f32>,
) -> (f32, f32);
// Provided methods
fn measure_paragraph(
&self,
paragraph: &NvTextParagraphView,
max_width: Option<f32>,
) -> (f32, f32) { ... }
fn hit_test_paragraph(
&self,
paragraph: &NvTextParagraphView,
box_width: f32,
local_x: f32,
local_y: f32,
) -> Option<NodeId> { ... }
}Expand description
Pluggable text & multi-run paragraph measurement / hit-test provider used by layout engines.
Required Methods§
Provided Methods§
Sourcefn measure_paragraph(
&self,
paragraph: &NvTextParagraphView,
max_width: Option<f32>,
) -> (f32, f32)
fn measure_paragraph( &self, paragraph: &NvTextParagraphView, max_width: Option<f32>, ) -> (f32, f32)
Measures a compiled multi-run paragraph (NvTextParagraphView) under optional max_width.
Sourcefn hit_test_paragraph(
&self,
paragraph: &NvTextParagraphView,
box_width: f32,
local_x: f32,
local_y: f32,
) -> Option<NodeId>
fn hit_test_paragraph( &self, paragraph: &NvTextParagraphView, box_width: f32, local_x: f32, local_y: f32, ) -> Option<NodeId>
Hit-tests content-box local (local_x, local_y) inside a paragraph laid out to
box_width, returning the hit run’s owning NodeId (None on trailing whitespace/miss).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".