Struct font_types::Fixed
source · pub struct Fixed(_);
Expand description
32-bit signed fixed point number with 16 bits of fraction.
Implementations§
source§impl Fixed
impl Fixed
sourcepub const fn from_bits(bits: i32) -> Self
pub const fn from_bits(bits: i32) -> Self
Creates a new fixed point value from the underlying bit representation.
sourcepub fn wrapping_add(self, other: Self) -> Self
pub fn wrapping_add(self, other: Self) -> Self
Wrapping addition.
sourcepub const fn saturating_add(self, other: Self) -> Self
pub const fn saturating_add(self, other: Self) -> Self
Saturating addition.
sourcepub const fn wrapping_sub(self, other: Self) -> Self
pub const fn wrapping_sub(self, other: Self) -> Self
Wrapping substitution.
sourcepub const fn saturating_sub(self, other: Self) -> Self
pub const fn saturating_sub(self, other: Self) -> Self
Saturating substitution.
sourcepub const fn to_be_bytes(self) -> [u8; 4]
pub const fn to_be_bytes(self) -> [u8; 4]
The representation of this number as a big-endian byte array.
source§impl Fixed
impl Fixed
sourcepub const fn to_i32(self) -> i32
pub const fn to_i32(self) -> i32
Converts a 16.16 fixed point value to a 32 bit integer, rounding off the fractional bits.
sourcepub const fn to_f26dot6(self) -> F26Dot6
pub const fn to_f26dot6(self) -> F26Dot6
Converts a 16.16 to 26.6 fixed point value.
sourcepub const fn to_f2dot14(self) -> F2Dot14
pub const fn to_f2dot14(self) -> F2Dot14
Converts a 16.16 to 2.14 fixed point value.
This specific conversion is defined by the spec: https://learn.microsoft.com/en-us/typography/opentype/spec/otvaroverview#coordinate-scales-and-normalization
“5. Convert the final, normalized 16.16 coordinate value to 2.14 by this method: add 0x00000002, and sign-extend shift to the right by 2.”
Trait Implementations§
source§impl AddAssign<Fixed> for Fixed
impl AddAssign<Fixed> for Fixed
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+=
operation. Read moresource§impl DivAssign<Fixed> for Fixed
impl DivAssign<Fixed> for Fixed
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/=
operation. Read moresource§impl MulAssign<Fixed> for Fixed
impl MulAssign<Fixed> for Fixed
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moresource§impl Ord for Fixed
impl Ord for Fixed
source§impl PartialEq<Fixed> for Fixed
impl PartialEq<Fixed> for Fixed
source§impl PartialOrd<Fixed> for Fixed
impl PartialOrd<Fixed> for Fixed
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl SubAssign<Fixed> for Fixed
impl SubAssign<Fixed> for Fixed
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-=
operation. Read more