use super::*;
impl Default for TextStyle {
#[inline(always)]
fn default() -> Self {
Self {
family: FontFamily::Sans,
font_size: 14.0,
weight: FontWeight::Normal,
line_height: 1.4,
letter_spacing: 0.0,
align: TextAlign::Left,
overflow: TextOverflow::Wrap,
color: COLOR_BLACK,
italic: false,
underline: false,
strikethrough: false,
selectable: false,
selectable_explicit: false,
selection_color: None,
}
}
}
impl TextStyle {
#[must_use]
#[inline(always)]
pub fn selection_color(&self) -> Option<Color> {
let Self {
selection_color, ..
} = *self;
selection_color
}
#[must_use]
#[inline(always)]
pub(crate) fn same_layout_metrics(&self, other: &Self) -> bool {
self.get_family() == other.get_family()
&& self.get_font_size() == other.get_font_size()
&& self.get_weight() == other.get_weight()
&& self.get_line_height() == other.get_line_height()
&& self.get_letter_spacing() == other.get_letter_spacing()
&& self.get_align() == other.get_align()
&& self.get_overflow() == other.get_overflow()
&& self.get_italic() == other.get_italic()
}
}
impl FontWeight {
#[must_use]
#[inline(always)]
pub const fn numeric(&self) -> u16 {
match *self {
Self::Light => 300,
Self::Normal => 400,
Self::Medium => 500,
Self::SemiBold => 600,
Self::Bold => 700,
}
}
#[must_use]
#[inline(always)]
pub const fn is_bold(&self) -> bool {
matches!(*self, Self::SemiBold | Self::Bold)
}
}