Struct tetra::graphics::text::Text[][src]

pub struct Text { /* fields omitted */ }
Expand description

A piece of text that can be rendered.

Performance

The layout and geometry of the text is cached after the first time it is calculated, making subsequent renders much faster. If your text stays the same from frame to frame, reusing the Text object will be much faster than recreating it.

Examples

The text example demonstrates how to load a font and then draw some text.

Implementations

Creates a new Text, with the given content and font.

Creates a new wrapped Text, with the given content, font and maximum width.

If a word is too long to fit, it may extend beyond the max width - use get_bounds if you need to find the actual bounds of the text.

Draws the text to the screen (or to a canvas, if one is enabled).

Returns a reference to the content of the text.

Sets the content of the text.

Calling this function will cause a re-layout of the text the next time it is rendered.

Gets the font of the text.

Sets the font of the text.

Calling this function will cause a re-layout of the text the next time it is rendered.

Gets the maximum width of the text, if one is set.

If a word is too long to fit, it may extend beyond this width - use get_bounds if you need to find the actual bounds of the text.

Sets the maximum width of the text.

If Some is passed, word-wrapping will be enabled. If None is passed, it will be disabled.

If a word is too long to fit, it may extend beyond this width - use get_bounds if you need to find the actual bounds of the text.

Calling this function will cause a re-layout of the text the next time it is rendered.

Appends the given character to the end of the text.

Calling this function will cause a re-layout of the text the next time it is rendered.

Appends the given string slice to the end of the text.

Calling this function will cause a re-layout of the text the next time it is rendered.

Removes the last character from the text and returns it.

Returns None if the text is empty.

Calling this function will cause a re-layout of the text the next time it is rendered.

Get the outer bounds of the text when rendered to the screen.

If the text’s layout needs calculating, this method will do so.

Note that this method will not take into account the positioning applied to the text via DrawParams.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.