pub struct Text<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: FormattableText> Text<T>
impl<T: FormattableText> Text<T>
sourcepub fn new(text: T) -> Self
pub fn new(text: T) -> Self
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) -> Self
pub fn new_env(env: Environment, text: T) -> Self
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: FormattableText + ?Sized> AsMut<TextDisplay> for Text<T>
impl<T: FormattableText + ?Sized> AsMut<TextDisplay> for Text<T>
source§fn as_mut(&mut self) -> &mut TextDisplay
fn as_mut(&mut self) -> &mut TextDisplay
source§impl<T: FormattableText + ?Sized> AsRef<TextDisplay> for Text<T>
impl<T: FormattableText + ?Sized> AsRef<TextDisplay> for Text<T>
source§fn as_ref(&self) -> &TextDisplay
fn as_ref(&self) -> &TextDisplay
source§impl<T: EditableText + ?Sized> EditableTextApi for Text<T>
impl<T: EditableText + ?Sized> EditableTextApi for Text<T>
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: FormattableText + ?Sized> TextApi for Text<T>
impl<T: FormattableText + ?Sized> TextApi for Text<T>
source§fn display(&self) -> &TextDisplay
fn display(&self) -> &TextDisplay
TextDisplay
source§fn clone_string(&self) -> String
fn clone_string(&self) -> String
String
source§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 more