Trait kas_core::text::TextApiExt
source · [−]pub trait TextApiExt: TextApi {
Show 15 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
sourcefn update_env(&mut self, env: Environment) -> Result<bool, InvalidFontId>
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).
sourcefn try_prepare(&mut self) -> Result<bool, InvalidFontId>
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).
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.
sourcefn required_action(&self) -> Action
fn required_action(&self) -> Action
Get required action
Get the number of lines (after wrapping)
Find the line containing text index
Get the range of a line, by line number
sourcefn text_is_rtl(&self) -> Result<bool, NotReady>
fn text_is_rtl(&self) -> Result<bool, NotReady>
Get the directionality of the first line
Get the directionality of the current line
Find the text index for the glyph nearest the given pos
Find the text index nearest horizontal-coordinate x on line
sourcefn text_glyph_pos(&self, index: usize) -> Result<MarkerPosIter, NotReady>
fn text_glyph_pos(&self, index: usize) -> Result<MarkerPosIter, NotReady>
Find the starting position (top-left) of the glyph at the given index
Yield a sequence of positioned glyphs
See TextDisplay::glyphs.
Like TextDisplay::glyphs but with added effects