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.
Trait Implementations§
impl StructuralPartialEq for FontSpec
Auto Trait Implementations§
impl Freeze for FontSpec
impl RefUnwindSafe for FontSpec
impl Send for FontSpec
impl Sync for FontSpec
impl Unpin for FontSpec
impl UnsafeUnpin for FontSpec
impl UnwindSafe for FontSpec
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