Trait kas_core::text::TextApiExt

source ·
pub trait TextApiExt: TextApi {
Show 15 methods // Provided methods fn update_env(&mut self, env: Environment) -> Result<bool, InvalidFontId> { ... } fn try_prepare(&mut self) -> Result<bool, InvalidFontId> { ... } fn bounding_box(&self) -> Result<(Vec2, Vec2), NotReady> { ... } fn required_action(&self) -> Action { ... } fn num_lines(&self) -> Result<usize, NotReady> { ... } fn find_line( &self, index: usize ) -> Result<Option<(usize, Range<usize>)>, NotReady> { ... } fn line_range(&self, line: usize) -> Result<Option<Range<usize>>, NotReady> { ... } fn text_is_rtl(&self) -> Result<bool, NotReady> { ... } fn line_is_rtl(&self, line: usize) -> Result<Option<bool>, NotReady> { ... } fn text_index_nearest(&self, pos: Vec2) -> Result<usize, NotReady> { ... } fn line_index_nearest( &self, line: usize, x: f32 ) -> Result<Option<usize>, NotReady> { ... } fn text_glyph_pos(&self, index: usize) -> Result<MarkerPosIter, NotReady> { ... } fn glyphs<F>(&self, f: F) -> Result<(), NotReady> where F: FnMut(FaceId, f32, Glyph) { ... } fn glyphs_with_effects<X, F, G>( &self, effects: &[Effect<X>], default_aux: X, f: F, g: G ) -> Result<(), NotReady> where X: Copy, F: FnMut(FaceId, f32, Glyph, usize, X), G: FnMut(f32, f32, f32, f32, usize, X) { ... } fn highlight_range<F>( &self, range: Range<usize>, f: F ) -> Result<(), NotReady> where F: FnMut(Vec2, Vec2) { ... }
}
Expand description

Extension trait over TextApi

Provided Methods§

source

fn update_env(&mut self, env: Environment) -> Result<bool, InvalidFontId>

Update the environment and do full preparation

Fully prepares the text. This is equivalent to calling TextApi::set_env followed by TextApi::prepare.

Returns true if at least some action is performed and the text exceeds the allocated bounds (Environment::bounds).

source

fn try_prepare(&mut self) -> Result<bool, InvalidFontId>

Prepare text for display, failing fast if fonts are not loaded

This is identical to [Self::prepare] except that it will fail fast in case no fonts have been loaded yet (see fonts::any_loaded).

source

fn bounding_box(&self) -> Result<(Vec2, Vec2), NotReady>

Get the size of the required bounding box

This is the position of the upper-left and lower-right corners of a bounding box on content. Alignment and input bounds do affect the result.

source

fn required_action(&self) -> Action

Get required action

source

fn num_lines(&self) -> Result<usize, NotReady>

Get the number of lines (after wrapping)

See TextDisplay::num_lines.

source

fn find_line( &self, index: usize ) -> Result<Option<(usize, Range<usize>)>, NotReady>

Find the line containing text index

See TextDisplay::find_line.

source

fn line_range(&self, line: usize) -> Result<Option<Range<usize>>, NotReady>

Get the range of a line, by line number

See TextDisplay::line_range.

source

fn text_is_rtl(&self) -> Result<bool, NotReady>

Get the directionality of the first line

source

fn line_is_rtl(&self, line: usize) -> Result<Option<bool>, NotReady>

Get the directionality of the current line

See TextDisplay::line_is_rtl.

source

fn text_index_nearest(&self, pos: Vec2) -> Result<usize, NotReady>

Find the text index for the glyph nearest the given pos

See TextDisplay::text_index_nearest.

source

fn line_index_nearest( &self, line: usize, x: f32 ) -> Result<Option<usize>, NotReady>

Find the text index nearest horizontal-coordinate x on line

See TextDisplay::line_index_nearest.

source

fn text_glyph_pos(&self, index: usize) -> Result<MarkerPosIter, NotReady>

Find the starting position (top-left) of the glyph at the given index

See TextDisplay::text_glyph_pos.

source

fn glyphs<F>(&self, f: F) -> Result<(), NotReady>
where F: FnMut(FaceId, f32, Glyph),

Yield a sequence of positioned glyphs

See TextDisplay::glyphs.

source

fn glyphs_with_effects<X, F, G>( &self, effects: &[Effect<X>], default_aux: X, f: F, g: G ) -> Result<(), NotReady>
where X: Copy, F: FnMut(FaceId, f32, Glyph, usize, X), G: FnMut(f32, f32, f32, f32, usize, X),

Like TextDisplay::glyphs but with added effects

See TextDisplay::glyphs_with_effects.

source

fn highlight_range<F>(&self, range: Range<usize>, f: F) -> Result<(), NotReady>
where F: FnMut(Vec2, Vec2),

Yield a sequence of rectangles to highlight a given text range

Calls f(top_left, bottom_right) for each highlighting rectangle.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> TextApiExt for T
where T: TextApi + ?Sized,