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§
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
).
sourcefn bounding_box(&self) -> Result<(Vec2, Vec2), NotReady>
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.
sourcefn required_action(&self) -> Action
fn required_action(&self) -> Action
Get required action
sourcefn find_line(
&self,
index: usize
) -> Result<Option<(usize, Range<usize>)>, NotReady>
fn find_line(
&self,
index: usize
) -> Result<Option<(usize, Range<usize>)>, NotReady>
Find the line containing text index
sourcefn line_range(&self, line: usize) -> Result<Option<Range<usize>>, NotReady>
fn line_range(&self, line: usize) -> Result<Option<Range<usize>>, NotReady>
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
sourcefn line_is_rtl(&self, line: usize) -> Result<Option<bool>, NotReady>
fn line_is_rtl(&self, line: usize) -> Result<Option<bool>, NotReady>
Get the directionality of the current line
sourcefn text_index_nearest(&self, pos: Vec2) -> Result<usize, NotReady>
fn text_index_nearest(&self, pos: Vec2) -> Result<usize, NotReady>
Find the text index for the glyph nearest the given pos
sourcefn line_index_nearest(
&self,
line: usize,
x: f32
) -> Result<Option<usize>, NotReady>
fn line_index_nearest(
&self,
line: usize,
x: f32
) -> Result<Option<usize>, NotReady>
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
sourcefn num_glyphs(&self) -> usize
fn num_glyphs(&self) -> usize
num_glyphs
only.Get the number of glyphs
sourcefn glyphs<F: FnMut(FaceId, f32, Glyph)>(&self, f: F) -> Result<(), NotReady>
fn glyphs<F: FnMut(FaceId, f32, Glyph)>(&self, f: F) -> Result<(), NotReady>
Yield a sequence of positioned glyphs
See TextDisplay::glyphs
.