pub struct Text { /* private fields */ }Expand description
Drawable text object. Essentially a list of TextFragment’s
and some cached size information.
It implements Drawable so it can be drawn immediately with
graphics::draw(), or many of them can be queued with graphics::queue_text()
and then all drawn at once with graphics::draw_queued_text().
Implementations§
Source§impl Text
impl Text
Sourcepub fn new<F>(fragment: F) -> Textwhere
F: Into<TextFragment>,
pub fn new<F>(fragment: F) -> Textwhere
F: Into<TextFragment>,
Creates a Text from a TextFragment.
let text = Text::new("foo");Sourcepub fn add<F>(&mut self, fragment: F) -> &mut Textwhere
F: Into<TextFragment>,
pub fn add<F>(&mut self, fragment: F) -> &mut Textwhere
F: Into<TextFragment>,
Appends a TextFragment to the Text.
Sourcepub fn fragments(&self) -> &[TextFragment]
pub fn fragments(&self) -> &[TextFragment]
Returns a read-only slice of all TextFragment’s.
Sourcepub fn fragments_mut(&mut self) -> &mut [TextFragment]
pub fn fragments_mut(&mut self) -> &mut [TextFragment]
Returns a mutable slice with all fragments.
Sourcepub fn set_bounds<P>(&mut self, bounds: P, alignment: Align) -> &mut Text
pub fn set_bounds<P>(&mut self, bounds: P, alignment: Align) -> &mut Text
Specifies rectangular dimensions to try and fit contents inside of,
by wrapping, and alignment within the bounds. To disable wrapping,
give it a layout with f32::INF for the x value.
Sourcepub fn set_font(&mut self, font: Font, font_scale: PxScale) -> &mut Text
pub fn set_font(&mut self, font: Font, font_scale: PxScale) -> &mut Text
Specifies text’s font and font scale; used for fragments that don’t have their own.
Sourcepub fn glyph_positions(&self, context: &Context) -> Ref<'_, Vec<Point2<f32>>>
pub fn glyph_positions(&self, context: &Context) -> Ref<'_, Vec<Point2<f32>>>
Returns a Vec containing the coordinates of the formatted and wrapped text.
Sourcepub fn dimensions(&self, context: &Context) -> Rect
pub fn dimensions(&self, context: &Context) -> Rect
Returns a Rect containing the width and height of the formatted and wrapped text.
Trait Implementations§
Source§impl Drawable for Text
impl Drawable for Text
Source§fn draw(
&self,
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
param: DrawParam,
) -> GameResult
fn draw( &self, ctx: &mut Context, quad_ctx: &mut GraphicsContext, param: DrawParam, ) -> GameResult
fn dimensions(&self, ctx: &mut Context) -> Option<Rect>
Source§fn set_blend_mode(&mut self, mode: Option<BlendMode>)
fn set_blend_mode(&mut self, mode: Option<BlendMode>)
graphics::set_blend_mode().
If None is set, defers to the blend mode set by
graphics::set_blend_mode().Source§fn blend_mode(&self) -> Option<BlendMode>
fn blend_mode(&self) -> Option<BlendMode>
Auto Trait Implementations§
impl !Freeze for Text
impl !RefUnwindSafe for Text
impl Send for Text
impl !Sync for Text
impl Unpin for Text
impl UnwindSafe for Text
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more