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
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 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<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
source§impl<T> TextApiExt for Twhere
T: TextApi + ?Sized,
impl<T> TextApiExt for Twhere
T: TextApi + ?Sized,
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 more