pub struct FontWeight(/* private fields */);Expand description
Visual weight class of a font, typically on a scale from 1 to 1000.
The default value is FontWeight::NORMAL or 400.
In variable fonts, this can be controlled with the wght axis. This
is a u16 so that it can represent the same range of values as the
wght axis.
See https://fonts.google.com/knowledge/glossary/weight
In CSS, this corresponds to the font-weight property.
Implementations§
Source§impl FontWeight
impl FontWeight
Sourcepub const EXTRA_LIGHT: Self
pub const EXTRA_LIGHT: Self
Weight value of 200.
Sourcepub const SEMI_LIGHT: Self
pub const SEMI_LIGHT: Self
Weight value of 350.
Sourcepub const EXTRA_BOLD: Self
pub const EXTRA_BOLD: Self
Weight value of 800.
Sourcepub const EXTRA_BLACK: Self
pub const EXTRA_BLACK: Self
Weight value of 950.
Source§impl FontWeight
impl FontWeight
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Parses a CSS style font weight attribute.
This function accepts only normal, bold and numeric values.
§Examples
assert_eq!(FontWeight::parse("normal"), Some(FontWeight::NORMAL));
assert_eq!(FontWeight::parse("bold"), Some(FontWeight::BOLD));
assert_eq!(FontWeight::parse("850"), Some(FontWeight::new(850)));
assert_eq!(FontWeight::parse("invalid"), None);Trait Implementations§
Source§impl Clone for FontWeight
impl Clone for FontWeight
Source§fn clone(&self) -> FontWeight
fn clone(&self) -> FontWeight
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for FontWeight
Source§impl Debug for FontWeight
impl Debug for FontWeight
Source§impl Default for FontWeight
impl Default for FontWeight
Source§impl<'de> Deserialize<'de> for FontWeight
impl<'de> Deserialize<'de> for FontWeight
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<FontWeight, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<FontWeight, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for FontWeight
impl Display for FontWeight
impl Eq for FontWeight
Source§impl From<FontWeight> for FontWeight
impl From<FontWeight> for FontWeight
Source§fn from(weight: FontWeight) -> Self
fn from(weight: FontWeight) -> Self
Converts to this type from the input type.
Source§impl Hash for FontWeight
impl Hash for FontWeight
Source§impl Ord for FontWeight
impl Ord for FontWeight
Source§fn cmp(&self, other: &FontWeight) -> Ordering
fn cmp(&self, other: &FontWeight) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for FontWeight
impl PartialEq for FontWeight
Source§fn eq(&self, other: &FontWeight) -> bool
fn eq(&self, other: &FontWeight) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for FontWeight
impl PartialOrd for FontWeight
Source§impl Serialize for FontWeight
impl Serialize for FontWeight
impl StructuralPartialEq for FontWeight
Auto Trait Implementations§
impl Freeze for FontWeight
impl RefUnwindSafe for FontWeight
impl Send for FontWeight
impl Sync for FontWeight
impl Unpin for FontWeight
impl UnsafeUnpin for FontWeight
impl UnwindSafe for FontWeight
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
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.