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>) -> TextStyle
pub fn with_weight(self, weight: u16) -> TextStyle
Sourcepub fn with_size(self, font_size: f32) -> TextStyle
pub fn with_size(self, font_size: f32) -> TextStyle
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) -> TextStyle
pub fn with_shadow(self, shadow: Shadow) -> TextStyle
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) -> TextStyle
pub fn with_align(self, align: TextAlign) -> TextStyle
pub fn with_max_lines(self, max_lines: u16) -> TextStyle
pub fn with_ellipsis(self, ellipsis: bool) -> TextStyle
pub fn with_line_height(self, line_height: f32) -> TextStyle
pub fn with_letter_spacing(self, letter_spacing: f32) -> TextStyle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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