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) -> FontSpec
pub fn new(family: impl Into<String>, size: f32, weight: u16) -> FontSpec
Construct a FontSpec with explicit family/size/weight; the
typographic extras default to “no override”.
Sourcepub fn with_style(self, style: FontStyle) -> FontSpec
pub fn with_style(self, style: FontStyle) -> FontSpec
Builder: set the slant FontStyle.
Sourcepub fn with_letter_spacing(self, letter_spacing: f32) -> FontSpec
pub fn with_letter_spacing(self, letter_spacing: f32) -> FontSpec
Builder: set additional letter spacing in points.
Sourcepub fn with_line_height(self, line_height: f32) -> FontSpec
pub fn with_line_height(self, line_height: f32) -> FontSpec
Builder: set the line height (leading) in points.
Sourcepub fn with_feature(self, feature: FontFeature) -> FontSpec
pub fn with_feature(self, feature: FontFeature) -> FontSpec
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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