Struct kas_core::text::Text

source ·
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§

Construct from a text model

This struct must be made ready for usage by calling Text::prepare.

Construct from a text model and environment

This struct must be made ready for usage by calling Text::prepare.

Clone the formatted text

Extract text object, discarding the rest

Access the formattable text object

Set the text

One must call Text::prepare afterwards and may wish to inspect its return value to check the size allocation meets requirements.

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§

Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Insert a char at the given position Read more
Replace a section of text Read more
Set text to a raw String Read more
Swap the raw text with a String Read more
Read the TextDisplay
Access whole text as contiguous str Read more
Clone the unformatted text as a String
Read the environment
Set the environment Read more
Require an action Read more
Prepare text runs Read more
Measure required width, up to some limit Read more
Measure required vertical height, wrapping as configured Read more
Prepare text for display, as necessary Read more
Get the sequence of effect tokens Read more
Length of text Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Cast from Self to T Read more
Try converting from Self to T Read more
Try approximate conversion from Self to T Read more
Cast approximately from Self to T Read more
Cast to integer, truncating Read more
Cast to the nearest integer Read more
Cast the floor to an integer Read more
Cast the ceiling to an integer Read more
Try converting to integer with truncation Read more
Try converting to the nearest integer Read more
Try converting the floor to an integer Read more
Try convert the ceiling to an integer Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Update the environment and do full preparation Read more
Prepare text for display, failing fast if fonts are not loaded Read more
Get the size of the required bounding box Read more
Get required action
Get the number of lines (after wrapping) Read more
Find the line containing text index Read more
Get the range of a line, by line number Read more
Get the directionality of the first line
Get the directionality of the current line Read more
Find the text index for the glyph nearest the given pos Read more
Find the text index nearest horizontal-coordinate x on line Read more
Find the starting position (top-left) of the glyph at the given index Read more
Yield a sequence of positioned glyphs Read more
Like TextDisplay::glyphs but with added effects Read more
Yield a sequence of rectangles to highlight a given text range Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.