Skip to main content

Weight

Struct Weight 

Source
pub struct Weight(f32);
Expand description

How heavy a design is, typically from 1.0 to 1000.0.

In variable fonts, this can be controlled with the wght axis.

See https://fonts.google.com/knowledge/glossary/weight

Tuple Fields§

§0: f32

Implementations§

Source§

impl Weight

Source

pub const THIN: Self

Weight value of 100.

Source

pub const EXTRA_LIGHT: Self

Weight value of 200.

Source

pub const LIGHT: Self

Weight value of 300.

Source

pub const SEMI_LIGHT: Self

Weight value of 350.

Source

pub const NORMAL: Self

Weight value of 400.

Source

pub const MEDIUM: Self

Weight value of 500.

Source

pub const SEMI_BOLD: Self

Weight value of 600.

Source

pub const BOLD: Self

Weight value of 700.

Source

pub const EXTRA_BOLD: Self

Weight value of 800.

Source

pub const BLACK: Self

Weight value of 900.

Source

pub const EXTRA_BLACK: Self

Weight value of 950.

Source

pub const fn new(weight: f32) -> Self

Creates a weight with the given value.

Source

fn from_name(name: &str) -> Self

Returns the weight for a PostScript Weight name, such as “Bold” or “SemiBold”.

Names are matched without regard to case, spaces, hyphens or underscores. An unknown name returns the normal weight.

Source

pub const fn value(self) -> f32

Returns the weight’s value.

Trait Implementations§

Source§

impl Clone for Weight

Source§

fn clone(&self) -> Weight

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Weight

Source§

impl Debug for Weight

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Weight

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Weight

Source§

fn eq(&self, other: &Weight) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Weight

Source§

fn partial_cmp(&self, other: &Weight) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Weight

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.