Struct FontWeight
pub struct FontWeight(/* private fields */);Expand description
Visual weight class of a font, typically on a scale from 1.0 to 1000.0.
The default value is FontWeight::NORMAL or 400.0.
In variable fonts, this can be controlled with the wght axis. This
is an f32 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§
§impl FontWeight
impl FontWeight
pub const THIN: FontWeight
pub const THIN: FontWeight
Weight value of 100.
pub const EXTRA_LIGHT: FontWeight
pub const EXTRA_LIGHT: FontWeight
Weight value of 200.
pub const LIGHT: FontWeight
pub const LIGHT: FontWeight
Weight value of 300.
pub const SEMI_LIGHT: FontWeight
pub const SEMI_LIGHT: FontWeight
Weight value of 350.
pub const NORMAL: FontWeight
pub const NORMAL: FontWeight
Weight value of 400. This is the default value.
pub const MEDIUM: FontWeight
pub const MEDIUM: FontWeight
Weight value of 500.
pub const SEMI_BOLD: FontWeight
pub const SEMI_BOLD: FontWeight
Weight value of 600.
pub const BOLD: FontWeight
pub const BOLD: FontWeight
Weight value of 700.
pub const EXTRA_BOLD: FontWeight
pub const EXTRA_BOLD: FontWeight
Weight value of 800.
pub const BLACK: FontWeight
pub const BLACK: FontWeight
Weight value of 900.
pub const EXTRA_BLACK: FontWeight
pub const EXTRA_BLACK: FontWeight
Weight value of 950.
§impl FontWeight
impl FontWeight
pub fn new(weight: f32) -> FontWeight
pub fn new(weight: f32) -> FontWeight
Creates a new weight attribute with the given value.
pub fn parse(s: &str) -> Option<FontWeight>
pub fn parse(s: &str) -> Option<FontWeight>
Parses a CSS style font weight attribute.
§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.0)));
assert_eq!(FontWeight::parse("invalid"), None);§impl FontWeight
impl FontWeight
pub fn from_fontconfig(weight: i32) -> FontWeight
pub fn from_fontconfig(weight: i32) -> FontWeight
Creates a new weight attribute with the given value from Fontconfig.
The values are determined based on the fonts.conf documentation.
Trait Implementations§
§impl Clone for FontWeight
impl Clone for FontWeight
§fn clone(&self) -> FontWeight
fn clone(&self) -> FontWeight
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for FontWeight
impl Debug for FontWeight
§impl Default for FontWeight
impl Default for FontWeight
§fn default() -> FontWeight
fn default() -> FontWeight
§impl Display for FontWeight
impl Display for FontWeight
§impl PartialEq for FontWeight
impl PartialEq for FontWeight
§impl PartialOrd for FontWeight
impl PartialOrd for FontWeight
impl Copy 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.