pub struct FontSpec {
pub family: String,
pub size: f32,
pub weight: u16,
pub style: FontStyle,
pub letter_spacing: f32,
pub line_height: Option<f32>,
pub features: Vec<FontFeature>,
}Expand description
Font specification for UI text.
The three legacy fields (family, size, weight) plus the
FontSpec::new constructor are unchanged. The richer typographic fields
(style, letter_spacing, line_height, features) are additive and
default to “no override”, so existing call sites are unaffected.
Fields§
§family: StringFont family name.
size: f32Font size in points.
weight: u16Font weight (100 thin … 900 black; 400 is regular).
style: FontStyleSlant style (normal / italic / oblique).
letter_spacing: f32Additional inter-character spacing in points (0.0 = font default).
line_height: Option<f32>Line height (leading) in points. None uses the font’s natural metrics.
features: Vec<FontFeature>OpenType feature toggles applied to runs using this spec.
Implementations§
Source§impl FontSpec
impl FontSpec
Sourcepub fn new(family: impl Into<String>, size: f32, weight: u16) -> Self
pub fn new(family: impl Into<String>, size: f32, weight: u16) -> Self
Construct a FontSpec with explicit family/size/weight; the
typographic extras default to “no override”.
Sourcepub fn with_style(self, style: FontStyle) -> Self
pub fn with_style(self, style: FontStyle) -> Self
Builder: set the slant FontStyle.
Sourcepub fn with_letter_spacing(self, letter_spacing: f32) -> Self
pub fn with_letter_spacing(self, letter_spacing: f32) -> Self
Builder: set additional letter spacing in points.
Sourcepub fn with_line_height(self, line_height: f32) -> Self
pub fn with_line_height(self, line_height: f32) -> Self
Builder: set the line height (leading) in points.
Sourcepub fn with_feature(self, feature: FontFeature) -> Self
pub fn with_feature(self, feature: FontFeature) -> Self
Builder: append an OpenType FontFeature.
Sourcepub fn is_slanted(&self) -> bool
pub fn is_slanted(&self) -> bool
Returns true if the face is italic or oblique.