Trait kas_text::TextApiExt

source ·
pub trait TextApiExt: TextApi {
Show 16 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 num_glyphs(&self) -> usize { ... } fn glyphs<F: FnMut(FaceId, f32, Glyph)>(&self, f: F) -> Result<(), NotReady> { ... } 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§

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

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

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.

Get required action

Get the number of lines (after wrapping)

See TextDisplay::num_lines.

Find the line containing text index

See TextDisplay::find_line.

Get the range of a line, by line number

See TextDisplay::line_range.

Get the directionality of the first line

Get the directionality of the current line

See TextDisplay::line_is_rtl.

Find the text index for the glyph nearest the given pos

See TextDisplay::text_index_nearest.

Find the text index nearest horizontal-coordinate x on line

See TextDisplay::line_index_nearest.

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

See TextDisplay::text_glyph_pos.

Available on crate feature num_glyphs only.

Get the number of glyphs

See TextDisplay::num_glyphs.

Yield a sequence of positioned glyphs

See TextDisplay::glyphs.

Like TextDisplay::glyphs but with added effects

See TextDisplay::glyphs_with_effects.

Yield a sequence of rectangles to highlight a given text range

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

Implementors§