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§
§impl<T> Text<T>where
T: FormattableText,
impl<T> Text<T>where
T: FormattableText,
pub 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.
pub 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.
pub fn clone_text(&self) -> Twhere
T: Clone,
pub fn clone_text(&self) -> Twhere
T: Clone,
Clone the formatted text
pub fn take_text(self) -> T
pub fn take_text(self) -> T
Extract text object, discarding the rest
pub 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.
pub 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§
§impl<T> AsMut<TextDisplay> for Text<T>where
T: FormattableText + ?Sized,
impl<T> AsMut<TextDisplay> for Text<T>where
T: FormattableText + ?Sized,
§fn as_mut(&mut self) -> &mut TextDisplay
fn as_mut(&mut self) -> &mut TextDisplay
§impl<T> AsRef<TextDisplay> for Text<T>where
T: FormattableText + ?Sized,
impl<T> AsRef<TextDisplay> for Text<T>where
T: FormattableText + ?Sized,
§fn as_ref(&self) -> &TextDisplay
fn as_ref(&self) -> &TextDisplay
§impl<T> EditableTextApi for Text<T>where
T: EditableText + ?Sized,
impl<T> EditableTextApi for Text<T>where
T: EditableText + ?Sized,
§fn insert_char(&mut self, index: usize, c: char)
fn insert_char(&mut self, index: usize, c: char)
§fn replace_range(&mut self, range: Range<usize>, replace_with: &str)
fn replace_range(&mut self, range: Range<usize>, replace_with: &str)
§fn set_string(&mut self, string: String)
fn set_string(&mut self, string: String)
String Read more§fn swap_string(&mut self, string: &mut String)
fn swap_string(&mut self, string: &mut String)
String Read more§impl<T> TextApi for Text<T>where
T: FormattableText + ?Sized,
impl<T> TextApi for Text<T>where
T: FormattableText + ?Sized,
§fn display(&self) -> &TextDisplay
fn display(&self) -> &TextDisplay
TextDisplay§fn clone_string(&self) -> String
fn clone_string(&self) -> String
String§fn env(&self) -> Environment
fn env(&self) -> Environment
§fn set_env(&mut self, env: Environment)
fn set_env(&mut self, env: Environment)
§fn require_action(&mut self, action: Action)
fn require_action(&mut self, action: Action)
§fn prepare_runs(&mut self) -> Result<(), InvalidFontId>
fn prepare_runs(&mut self) -> Result<(), InvalidFontId>
§fn measure_width(&mut self, limit: f32) -> Result<f32, InvalidFontId>
fn measure_width(&mut self, limit: f32) -> Result<f32, InvalidFontId>
limit Read more§fn measure_height(&mut self) -> Result<f32, InvalidFontId>
fn measure_height(&mut self) -> Result<f32, InvalidFontId>
§fn prepare(&mut self) -> Result<bool, InvalidFontId>
fn prepare(&mut self) -> Result<bool, InvalidFontId>
§fn effect_tokens(&self) -> &[Effect<()>]
fn effect_tokens(&self) -> &[Effect<()>]
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§
§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
§fn cast_approx(self) -> T
fn cast_approx(self) -> T
§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
§fn cast_floor(self) -> T
fn cast_floor(self) -> T
§fn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
§fn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
§fn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
§fn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<T> TextApiExt for Twhere
T: TextApi + ?Sized,
impl<T> TextApiExt for Twhere
T: TextApi + ?Sized,
§fn update_env(&mut self, env: Environment) -> Result<bool, InvalidFontId>
fn update_env(&mut self, env: Environment) -> Result<bool, InvalidFontId>
§fn try_prepare(&mut self) -> Result<bool, InvalidFontId>
fn try_prepare(&mut self) -> Result<bool, InvalidFontId>
§fn bounding_box(&self) -> Result<(Vec2, Vec2), NotReady>
fn bounding_box(&self) -> Result<(Vec2, Vec2), NotReady>
§fn required_action(&self) -> Action
fn required_action(&self) -> Action
§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 more§fn line_range(&self, line: usize) -> Result<Option<Range<usize>>, NotReady>
fn line_range(&self, line: usize) -> Result<Option<Range<usize>>, NotReady>
§fn text_is_rtl(&self) -> Result<bool, NotReady>
fn text_is_rtl(&self) -> Result<bool, NotReady>
§fn line_is_rtl(&self, line: usize) -> Result<Option<bool>, NotReady>
fn line_is_rtl(&self, line: usize) -> Result<Option<bool>, NotReady>
§fn text_index_nearest(&self, pos: Vec2) -> Result<usize, NotReady>
fn text_index_nearest(&self, pos: Vec2) -> Result<usize, NotReady>
pos Read more