pub struct TextStyle {
pub font: FontId,
pub px_size: u16,
pub color: Color,
pub decoration: TextDecoration,
}Expand description
Font and color for text layout and draw commands.
§Examples
use ailloli_ui_core::{Color, FontId, TextStyle};
let style = TextStyle::new(FontId::Ui, 14, Color::WHITE);
assert_eq!(style.px_size, 14);Fields§
§font: FontIdBuilt-in font-family slot.
px_size: u16Font size in logical pixels.
color: ColorLinear-RGBA glyph and decoration color.
decoration: TextDecorationPaint-only line decoration.
Implementations§
Source§impl TextStyle
impl TextStyle
Sourcepub const fn new(font: FontId, px_size: u16, color: Color) -> Self
pub const fn new(font: FontId, px_size: u16, color: Color) -> Self
Creates undecorated text with the supplied font, size, and color.
A zero pixel size is representable and left for the text engine to interpret.
§Examples
use ailloli_ui_core::{Color, FontId, TextDecoration, TextStyle};
let style = TextStyle::new(FontId::Mono, 13, Color::BLACK);
assert_eq!(style.decoration, TextDecoration::None);Sourcepub const fn underline(self) -> Self
pub const fn underline(self) -> Self
Returns this style with TextDecoration::Underline.
§Examples
use ailloli_ui_core::{Color, FontId, TextDecoration, TextStyle};
assert_eq!(TextStyle::new(FontId::Ui, 14, Color::WHITE).underline().decoration, TextDecoration::Underline);Sourcepub const fn without_decoration(self) -> Self
pub const fn without_decoration(self) -> Self
Returns this style with TextDecoration::None.
§Examples
use ailloli_ui_core::{Color, FontId, TextDecoration, TextStyle};
let style = TextStyle::new(FontId::Ui, 14, Color::WHITE).underline().without_decoration();
assert_eq!(style.decoration, TextDecoration::None);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 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