pub struct F2DOT14(/* private fields */);Expand description
The OpenType F2DOT14 type, a 2.14-bit signed fixed-point type.
Implementations§
Source§impl F2DOT14
impl F2DOT14
Sourcepub const MAX: Self
pub const MAX: Self
The largest value that can be represented by this type.
§Examples
assert_eq!(F2DOT14::MAX, 1.999939);Sourcepub const PRECISION: u32
pub const PRECISION: u32
The amount of decimal places the type can accurately represent.
§Examples
assert_eq!(F2DOT14::PRECISION, 4);Sourcepub const fn new(num: f32) -> Option<Self>
pub const fn new(num: f32) -> Option<Self>
§Examples
use ttf_view::types::F2DOT14;
assert_eq!(F2DOT14::new(-0.125).unwrap(), -0.125);
assert_eq!(F2DOT14::new(1.99609375).unwrap(), 1.99609375);
assert_eq!(F2DOT14::new(123456.78), None);
// numbers are rounded towards the closest value representable by F2DOT14
assert_eq!(F2DOT14::new(0.5156247).unwrap(), 0.515625);
assert_eq!(F2DOT14::new(0.5156250).unwrap(), 0.515625);
assert_eq!(F2DOT14::new(0.5156254).unwrap(), 0.515625);Sourcepub const unsafe fn new_unchecked(num: f32) -> Self
pub const unsafe fn new_unchecked(num: f32) -> Self
Sourcepub const fn from_be_bytes(bytes: [u8; 2]) -> Self
pub const fn from_be_bytes(bytes: [u8; 2]) -> Self
Creates a F2DOT14 from big-endian bytes.
TODO: # Examples
Sourcepub const fn to_be_bytes(self) -> [u8; 2]
pub const fn to_be_bytes(self) -> [u8; 2]
Gets this F2DOT14’s big-endian bytes.
TODO: # Examples
Sourcepub const fn frac_num(&self) -> i16
pub const fn frac_num(&self) -> i16
Returns this F2DOT14 fraction’s numerator
(F2DOT14 represented as ).
TODO: # Examples
Sourcepub const fn round_to_precision(&self) -> f32
pub const fn round_to_precision(&self) -> f32
Trait Implementations§
impl Copy for F2DOT14
impl Eq for F2DOT14
Source§impl Ord for F2DOT14
impl Ord for F2DOT14
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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for F2DOT14
impl PartialOrd for F2DOT14
Source§impl PartialOrd<f32> for F2DOT14
impl PartialOrd<f32> for F2DOT14
impl StructuralPartialEq for F2DOT14
Auto Trait Implementations§
impl Freeze for F2DOT14
impl RefUnwindSafe for F2DOT14
impl Send for F2DOT14
impl Sync for F2DOT14
impl Unpin for F2DOT14
impl UnsafeUnpin for F2DOT14
impl UnwindSafe for F2DOT14
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