pub struct FontDescriptor {
pub family: String,
pub size_pt: f32,
pub weight: FontWeight,
pub italic: bool,
}Expand description
A portable font description: family, size, weight, and slant.
This descriptor is also the base the Canvas text work consumes; fallback chains, stretch, and variable-font axes stay out of the portable tier.
Fields§
§family: StringFont family name, for example Inter.
size_pt: f32Size in points.
weight: FontWeightWeight step.
italic: boolItalic (oblique) slant.
Implementations§
Source§impl FontDescriptor
impl FontDescriptor
Sourcepub fn new(family: impl Into<String>, size_pt: f32) -> Self
pub fn new(family: impl Into<String>, size_pt: f32) -> Self
Builds a regular-weight, upright descriptor.
Sourcepub fn with_weight(self, weight: FontWeight) -> Self
pub fn with_weight(self, weight: FontWeight) -> Self
Replaces the weight.
Sourcepub fn with_italic(self, italic: bool) -> Self
pub fn with_italic(self, italic: bool) -> Self
Replaces the slant.
Sourcepub fn validate(&self) -> PickerResult<()>
pub fn validate(&self) -> PickerResult<()>
Checks the family and size invariants.
A blank family is PickerError::EmptyFontFamily; a non-finite or
non-positive size is PickerError::InvalidFontSize.
Trait Implementations§
Source§impl Clone for FontDescriptor
impl Clone for FontDescriptor
Source§impl Debug for FontDescriptor
impl Debug for FontDescriptor
Source§impl PartialEq for FontDescriptor
impl PartialEq for FontDescriptor
impl StructuralPartialEq for FontDescriptor
Auto Trait Implementations§
impl Forget for FontDescriptor
impl Freeze for FontDescriptor
impl Move for FontDescriptor
impl RefUnwindSafe for FontDescriptor
impl Send for FontDescriptorwhere
RawVecInner: Send,
impl Sync for FontDescriptorwhere
RawVecInner: Sync,
impl Unpin for FontDescriptor
impl UnsafeUnpin for FontDescriptor
impl UnwindSafe for FontDescriptorwhere
RawVecInner: UnwindSafe,
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