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).
Sets the content of the text.
Calling this function will cause a re-layout of the text the next time it is rendered.
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
Auto Trait Implementations
impl !RefUnwindSafe for Text
impl !UnwindSafe for Text
Blanket Implementations
Mutably borrows from an owned value. Read more