pub struct FontSize {
pub numerator: u32,
pub denominator: u32,
}
Expand description
A fractional font scaling factor.
Fields§
§numerator: u32
The numerator of the fractional font scale.
denominator: u32
The denominator of the fractional font scale.
Implementations§
Source§impl FontSize
impl FontSize
Sourcepub const EXTRA_SMALL: Self
pub const EXTRA_SMALL: Self
An extra-small font size with a value of one-fifth.
Sourcepub const EXTRA_LARGE: Self
pub const EXTRA_LARGE: Self
An extra-large font size with a value of two-thirds.
Sourcepub const fn new(numerator: u32, denominator: u32) -> Self
pub const fn new(numerator: u32, denominator: u32) -> Self
Create a custom fractional font size.
If you want to create a font size from a floating-point size, use FontSize::from_float
instead.
Sourcepub fn from_float(size: f32) -> Result<Self, InvalidFontSizeError>
pub fn from_float(size: f32) -> Result<Self, InvalidFontSizeError>
Create a fractional font size from a floating-point size.
§Note
This function is lossy, but negligibly so. The highest the denominator can be is 10000.
§Errors
InvalidFontSizeError
if the given size is negative.
Trait Implementations§
impl Copy for FontSize
impl Eq for FontSize
impl StructuralPartialEq for FontSize
Auto Trait Implementations§
impl Freeze for FontSize
impl RefUnwindSafe for FontSize
impl Send for FontSize
impl Sync for FontSize
impl Unpin for FontSize
impl UnwindSafe for FontSize
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