pub struct TextStyle {
pub size: f32,
pub color: Color,
pub outline: Option<(Color, f32)>,
pub align: TextAlign,
}Expand description
How a string is drawn: size, color, optional outline, and alignment.
Each line of a multi-line string is aligned independently.
Fields§
§size: f32§color: Color§outline: Option<(Color, f32)>Outline color and width in pixels.
The outline is rasterized from the glyph’s distance field, so its thickness is
uniform around curves and corners. Width is clamped to
TextStyle::max_outline_width. Outlines of adjacent glyphs overlap slightly
where they meet, which is only visible if the outline color is translucent.
align: TextAlignImplementations§
Source§impl TextStyle
impl TextStyle
pub fn new(size: f32, color: Color) -> Self
pub fn outlined(self, color: Color, width: f32) -> Self
pub fn aligned(self, align: TextAlign) -> Self
Sourcepub fn max_outline_width(size: f32) -> f32
pub fn max_outline_width(size: f32) -> f32
Widest outline available at the given font size, in pixels.
The distance field baked into the glyph atlas has a fixed range, so the usable outline width grows with the font size. Wider requests are clamped to this value.
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