Skip to main content

TextMeasurer

Trait TextMeasurer 

Source
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§

Source

fn measure( &self, text: &str, style: &TextStyle<&str>, max_width: Option<f32>, ) -> (f32, f32)

Measures single-run text with resolved typography under an optional max_width constraint (Some(0.0) is a min-content probe). Returns (width, height) in logical points.

Provided Methods§

Source

fn measure_paragraph( &self, paragraph: &NvTextParagraphView, max_width: Option<f32>, ) -> (f32, f32)

Measures a compiled multi-run paragraph (NvTextParagraphView) under optional max_width.

Source

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".

Implementations on Foreign Types§

Source§

impl<T: TextMeasurer + ?Sized> TextMeasurer for Arc<T>

Source§

fn measure( &self, text: &str, style: &TextStyle<&str>, max_width: Option<f32>, ) -> (f32, f32)

Source§

fn measure_paragraph( &self, paragraph: &NvTextParagraphView, max_width: Option<f32>, ) -> (f32, f32)

Source§

fn hit_test_paragraph( &self, paragraph: &NvTextParagraphView, box_width: f32, local_x: f32, local_y: f32, ) -> Option<NodeId>

Implementors§