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§
Sourcefn rich_text(
&mut self,
text: &str,
spans: &[Span<'_>],
style: TextStyle<'_>,
) -> TextRun
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
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
Sourcefn caret_rect(
&mut self,
area: LogicalRect,
request: &TextRequest,
offset: usize,
upstream: bool,
) -> LogicalRect
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
Sourcefn range_rects<'a>(
&mut self,
area: LogicalRect,
request: &TextRequest,
range: Range<usize>,
scratch: &'a ScratchBuffer,
) -> Scratch<'a, LogicalRect>
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
Sourcefn resolve<'a>(
&mut self,
area: LogicalRect,
request: &TextRequest,
scale: f32,
scratch: &'a ScratchBuffer,
) -> Scratch<'a, PositionedGlyph>
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
Sourcefn rasterize(&mut self, key: GlyphKey) -> GlyphImage
fn rasterize(&mut self, key: GlyphKey) -> GlyphImage
equal keys must produce identical pixels and bearings
fn finish_frame(&mut self)
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".