Skip to main content

TextSystem

Trait TextSystem 

Source
pub trait TextSystem: 'static {
    // Required methods
    fn rich_text(
        &mut self,
        text: &str,
        spans: &[Span<'_>],
        style: TextStyle<'_>,
    ) -> TextRun;
    fn measure(
        &mut self,
        text: TextRun,
        max_width: Option<f32>,
        options: TextOptions,
    ) -> Fit<LogicalSize>;
    fn offset_at_position(
        &mut self,
        area: LogicalRect,
        request: &TextRequest,
        position: LogicalPoint,
    ) -> usize;
    fn caret_rect(
        &mut self,
        area: LogicalRect,
        request: &TextRequest,
        offset: usize,
        upstream: bool,
    ) -> LogicalRect;
    fn range_rects<'a>(
        &mut self,
        area: LogicalRect,
        request: &TextRequest,
        range: Range<usize>,
        scratch: &'a ScratchBuffer,
    ) -> Scratch<'a, LogicalRect>;
    fn resolve<'a>(
        &mut self,
        area: LogicalRect,
        request: &TextRequest,
        scale: f32,
        scratch: &'a ScratchBuffer,
    ) -> Scratch<'a, PositionedGlyph>;
    fn rasterize(&mut self, key: GlyphKey) -> GlyphImage;
    fn finish_frame(&mut self);

    // Provided method
    fn text_run(&mut self, text: &str, style: TextStyle<'_>) -> TextRun { ... }
}

Required Methods§

Source

fn rich_text( &mut self, text: &str, spans: &[Span<'_>], style: TextStyle<'_>, ) -> TextRun

registers geometry using span ranges and font attributes returned text runs remain valid until finish_frame

Source

fn measure( &mut self, text: TextRun, max_width: Option<f32>, options: TextOptions, ) -> Fit<LogicalSize>

Source

fn offset_at_position( &mut self, area: LogicalRect, request: &TextRequest, position: LogicalPoint, ) -> usize

Source

fn caret_rect( &mut self, area: LogicalRect, request: &TextRequest, offset: usize, upstream: bool, ) -> LogicalRect

returns the zero-width caret rectangle at offset upstream keeps an offset at a soft wrap on the line it ends

Source

fn range_rects<'a>( &mut self, area: LogicalRect, request: &TextRequest, range: Range<usize>, scratch: &'a ScratchBuffer, ) -> Scratch<'a, LogicalRect>

returns visual rectangles for range in scratch

Source

fn resolve<'a>( &mut self, area: LogicalRect, request: &TextRequest, scale: f32, scratch: &'a ScratchBuffer, ) -> Scratch<'a, PositionedGlyph>

returns positioned glyphs for painting in scratch returned glyph keys remain valid for rasterize until finish_frame

Source

fn rasterize(&mut self, key: GlyphKey) -> GlyphImage

equal keys must produce identical pixels and bearings

Source

fn finish_frame(&mut self)

Provided Methods§

Source

fn text_run(&mut self, text: &str, style: TextStyle<'_>) -> TextRun

registers geometry using the font attributes in style returned text runs remain valid until finish_frame

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§