pub struct Text<T>where
T: FormattableText + ?Sized,{ /* private fields */ }Expand description
Text, prepared for display in a given environment
This struct is composed of three parts: an Environment, a representation
of the FormattableText being displayed, and a TextDisplay object.
Most Functionality is implemented via the TextApi and TextApiExt
traits.
Implementations§
source§impl<T> Text<T>where
T: FormattableText,
impl<T> Text<T>where
T: FormattableText,
sourcepub fn new(text: T) -> Text<T>
pub fn new(text: T) -> Text<T>
Construct from a text model
This struct must be made ready for usage by calling Text::prepare.
sourcepub fn new_env(env: Environment, text: T) -> Text<T>
pub fn new_env(env: Environment, text: T) -> Text<T>
Construct from a text model and environment
This struct must be made ready for usage by calling Text::prepare.
sourcepub fn clone_text(&self) -> Twhere
T: Clone,
pub fn clone_text(&self) -> Twhere
T: Clone,
Clone the formatted text
sourcepub fn set_text(&mut self, text: T)
pub fn set_text(&mut self, text: T)
Set the text
One must call Text::prepare afterwards and may wish to inspect its
return value to check the size allocation meets requirements.
sourcepub fn set_and_try_prepare(&mut self, text: T) -> Result<bool, InvalidFontId>
pub fn set_and_try_prepare(&mut self, text: T) -> Result<bool, InvalidFontId>
Set the text and prepare (if any fonts are loaded)
Sets text regardless of other outcomes.
If fonts are not loaded, this fails fast (see fonts::any_loaded),
unlike other preparation methods.
Returns true if at least some action is performed and the text exceeds
the allocated bounds (Environment::bounds).
Trait Implementations§
source§impl<T> AsMut<TextDisplay> for Text<T>where
T: FormattableText + ?Sized,
impl<T> AsMut<TextDisplay> for Text<T>where
T: FormattableText + ?Sized,
source§fn as_mut(&mut self) -> &mut TextDisplay
fn as_mut(&mut self) -> &mut TextDisplay
source§impl<T> AsRef<TextDisplay> for Text<T>where
T: FormattableText + ?Sized,
impl<T> AsRef<TextDisplay> for Text<T>where
T: FormattableText + ?Sized,
source§fn as_ref(&self) -> &TextDisplay
fn as_ref(&self) -> &TextDisplay
source§impl<T> EditableTextApi for Text<T>where
T: EditableText + ?Sized,
impl<T> EditableTextApi for Text<T>where
T: EditableText + ?Sized,
source§fn insert_char(&mut self, index: usize, c: char)
fn insert_char(&mut self, index: usize, c: char)
source§fn replace_range(&mut self, range: Range<usize>, replace_with: &str)
fn replace_range(&mut self, range: Range<usize>, replace_with: &str)
source§fn set_string(&mut self, string: String)
fn set_string(&mut self, string: String)
String Read moresource§fn swap_string(&mut self, string: &mut String)
fn swap_string(&mut self, string: &mut String)
String Read moresource§impl<T> TextApi for Text<T>where
T: FormattableText + ?Sized,
impl<T> TextApi for Text<T>where
T: FormattableText + ?Sized,
source§fn display(&self) -> &TextDisplay
fn display(&self) -> &TextDisplay
TextDisplaysource§fn clone_string(&self) -> String
fn clone_string(&self) -> String
Stringsource§fn env(&self) -> Environment
fn env(&self) -> Environment
source§fn set_env(&mut self, env: Environment)
fn set_env(&mut self, env: Environment)
source§fn require_action(&mut self, action: Action)
fn require_action(&mut self, action: Action)
source§fn prepare_runs(&mut self) -> Result<(), InvalidFontId>
fn prepare_runs(&mut self) -> Result<(), InvalidFontId>
source§fn measure_width(&mut self, limit: f32) -> Result<f32, InvalidFontId>
fn measure_width(&mut self, limit: f32) -> Result<f32, InvalidFontId>
limit Read moresource§fn measure_height(&mut self) -> Result<f32, InvalidFontId>
fn measure_height(&mut self) -> Result<f32, InvalidFontId>
Auto Trait Implementations§
impl<T: ?Sized> RefUnwindSafe for Text<T>where
T: RefUnwindSafe,
impl<T: ?Sized> Send for Text<T>where
T: Send,
impl<T: ?Sized> Sync for Text<T>where
T: Sync,
impl<T: ?Sized> Unpin for Text<T>where
T: Unpin,
impl<T: ?Sized> UnwindSafe for Text<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
source§impl<T> TextApiExt for T
impl<T> TextApiExt for T
source§fn update_env(&mut self, env: Environment) -> Result<bool, InvalidFontId>
fn update_env(&mut self, env: Environment) -> Result<bool, InvalidFontId>
source§fn try_prepare(&mut self) -> Result<bool, InvalidFontId>
fn try_prepare(&mut self) -> Result<bool, InvalidFontId>
source§fn bounding_box(&self) -> Result<(Vec2, Vec2), NotReady>
fn bounding_box(&self) -> Result<(Vec2, Vec2), NotReady>
source§fn required_action(&self) -> Action
fn required_action(&self) -> Action
source§fn num_lines(&self) -> Result<usize, NotReady>
fn num_lines(&self) -> Result<usize, NotReady>
source§fn find_line(
&self,
index: usize
) -> Result<Option<(usize, Range<usize>)>, NotReady>
fn find_line( &self, index: usize ) -> Result<Option<(usize, Range<usize>)>, NotReady>
index Read moresource§fn line_range(&self, line: usize) -> Result<Option<Range<usize>>, NotReady>
fn line_range(&self, line: usize) -> Result<Option<Range<usize>>, NotReady>
source§fn line_is_rtl(&self, line: usize) -> Result<Option<bool>, NotReady>
fn line_is_rtl(&self, line: usize) -> Result<Option<bool>, NotReady>
source§fn text_index_nearest(&self, pos: Vec2) -> Result<usize, NotReady>
fn text_index_nearest(&self, pos: Vec2) -> Result<usize, NotReady>
pos Read moresource§fn text_glyph_pos(&self, index: usize) -> Result<MarkerPosIter, NotReady>
fn text_glyph_pos(&self, index: usize) -> Result<MarkerPosIter, NotReady>
source§fn glyphs<F>(&self, f: F) -> Result<(), NotReady>
fn glyphs<F>(&self, f: F) -> Result<(), NotReady>
source§fn glyphs_with_effects<X, F, G>(
&self,
effects: &[Effect<X>],
default_aux: X,
f: F,
g: G
) -> Result<(), NotReady>
fn glyphs_with_effects<X, F, G>( &self, effects: &[Effect<X>], default_aux: X, f: F, g: G ) -> Result<(), NotReady>
TextDisplay::glyphs but with added effects Read more