pub struct TextStyle {
pub font_size: f32,
pub paint: Paint,
pub shadow: Option<Shadow>,
pub weight: u16,
pub italic: bool,
pub align: TextAlign,
pub max_lines: Option<u16>,
pub ellipsis: bool,
pub line_height: Option<f32>,
pub letter_spacing: f32,
}Fields§
§font_size: f32§paint: Paint§shadow: Option<Shadow>§weight: u16OpenType weight axis: 400 is normal, 700 is bold. Selects the matching font face.
italic: bool§align: TextAlign§max_lines: Option<u16>Clamp the text to at most this many lines (None = unlimited). Lines beyond it are dropped.
ellipsis: boolWhen clamped by max_lines, replace the overflowing tail with an ellipsis (…).
line_height: Option<f32>Line height as a multiple of font_size (e.g. 1.5). None keeps the shaper’s natural line height, so the default renders byte-for-byte as before.
letter_spacing: f32Extra advance in logical pixels added after each glyph. 0.0 uses the font’s natural advances.
Implementations§
Source§impl TextStyle
impl TextStyle
pub fn new(font_size: f32, paint: impl Into<Paint>) -> Self
pub fn with_weight(self, weight: u16) -> Self
Sourcepub fn with_size(self, font_size: f32) -> Self
pub fn with_size(self, font_size: f32) -> Self
Overrides the size a style was built at, so a style carrying theme-resolved weight and slant can be re-sized without being rebuilt from scratch (and losing them).
Sourcepub fn with_shadow(self, shadow: Shadow) -> Self
pub fn with_shadow(self, shadow: Shadow) -> Self
Drops a shadow behind the glyphs — what keeps text legible over an image the style knows nothing about.
pub fn with_italic(self, italic: bool) -> Self
pub fn with_align(self, align: TextAlign) -> Self
pub fn with_max_lines(self, max_lines: u16) -> Self
pub fn with_ellipsis(self, ellipsis: bool) -> Self
pub fn with_line_height(self, line_height: f32) -> Self
pub fn with_letter_spacing(self, letter_spacing: f32) -> Self
Trait Implementations§
impl Copy for TextStyle
impl StructuralPartialEq for TextStyle
Auto Trait Implementations§
impl Freeze for TextStyle
impl RefUnwindSafe for TextStyle
impl Send for TextStyle
impl Sync for TextStyle
impl Unpin for TextStyle
impl UnsafeUnpin for TextStyle
impl UnwindSafe for TextStyle
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
Mutably borrows from an owned value. Read more