pub struct TextStyle {
pub font_size: Option<f32>,
pub font_weight: u16,
pub italic: bool,
pub color: Option<[u8; 4]>,
pub line_height: Option<f32>,
pub letter_spacing: f32,
pub underline: bool,
pub strikethrough: bool,
}Expand description
Text rendering style for labels and headings.
All fields have sensible defaults (400-weight, upright, theme colour). Use the builder methods to produce variant styles without repeating boilerplate.
§Example
use oxiui_core::TextStyle;
let style = TextStyle::default()
.with_size(18.0)
.with_weight(600)
.with_color([0, 0, 0, 255]);Fields§
§font_size: Option<f32>Font size in points (None = use the theme default).
font_weight: u16Font weight: 100 = thin, 400 = regular, 700 = bold, 900 = black.
italic: boolWhether the text is rendered with an italic face.
color: Option<[u8; 4]>Text colour in RGBA bytes (None = use the theme default).
line_height: Option<f32>Line height multiplier (None = platform/theme default of ~1.2).
letter_spacing: f32Additional horizontal space between glyphs, in pixels (0.0 = default).
underline: boolDraw a line beneath the text.
strikethrough: boolDraw a line through the middle of the text.
Implementations§
Source§impl TextStyle
impl TextStyle
Sourcepub fn with_weight(self, weight: u16) -> Self
pub fn with_weight(self, weight: u16) -> Self
Builder: override the font weight (100–900).
Sourcepub fn with_color(self, rgba: [u8; 4]) -> Self
pub fn with_color(self, rgba: [u8; 4]) -> Self
Builder: set an explicit RGBA colour override.
Sourcepub fn with_line_height(self, multiplier: f32) -> Self
pub fn with_line_height(self, multiplier: f32) -> Self
Builder: set the line height multiplier.
Sourcepub fn with_letter_spacing(self, spacing: f32) -> Self
pub fn with_letter_spacing(self, spacing: f32) -> Self
Builder: set the additional letter spacing in pixels.
Sourcepub fn with_underline(self, underline: bool) -> Self
pub fn with_underline(self, underline: bool) -> Self
Builder: enable or disable the underline decoration.
Sourcepub fn with_strikethrough(self, strikethrough: bool) -> Self
pub fn with_strikethrough(self, strikethrough: bool) -> Self
Builder: enable or disable the strikethrough decoration.
Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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