Skip to content

Commit

Permalink
Adds some helpful methods to TextFont
Browse files Browse the repository at this point in the history
  • Loading branch information
mnmaita committed Nov 13, 2024
1 parent a8c610a commit a176344
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crates/bevy_text/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,28 @@ pub struct TextFont {
}

impl TextFont {
/// Returns a new [`TextFont`] with the specified font face handle.
pub fn from_font(font: Handle<Font>) -> Self {
Self::default().with_font(font)
}

/// Returns a new [`TextFont`] with the specified font size.
pub fn from_font_size(font_size: f32) -> Self {
Self::default().with_font_size(font_size)
}

/// Returns this [`TextFont`] with the specified font face handle.
pub fn with_font(mut self, font: Handle<Font>) -> Self {
self.font = font;
self
}

/// Returns this [`TextFont`] with the specified font size.
pub const fn with_font_size(mut self, font_size: f32) -> Self {
self.font_size = font_size;
self
}

/// Returns this [`TextFont`] with the specified [`FontSmoothing`].
pub const fn with_font_smoothing(mut self, font_smoothing: FontSmoothing) -> Self {
self.font_smoothing = font_smoothing;
Expand Down

0 comments on commit a176344

Please sign in to comment.