pub struct Dim { /* private fields */ }Expand description
TeX-style dimension: width, height, depth, italic correction, mu.
Values are zenith-float software floats. One unit is one em at the current math style unless a method says otherwise.
§Examples
use latex_rust::Dim;
let half = Dim::ratio(1, 2);
assert!(half.eq_dim(&(&Dim::one() / &Dim::from_i64(2))));
assert!(!Dim::zero().eq_dim(&Dim::one()));Implementations§
Source§impl Dim
impl Dim
Sourcepub fn parse(s: &str) -> Self
pub fn parse(s: &str) -> Self
Parse a decimal string (including scientific form) with zenith-float.
Sourcepub fn from_font_units(units: i64, units_per_em: u16) -> Self
pub fn from_font_units(units: i64, units_per_em: u16) -> Self
Convert integer font units to em: units / units_per_em.
Sourcepub fn clamp_nonneg(&self) -> Self
pub fn clamp_nonneg(&self) -> Self
max(self, 0).
Sourcepub fn to_dec_string(&self) -> String
pub fn to_dec_string(&self) -> String
Decimal string from zenith-float (gold-stable for a given precision).
Sourcepub fn to_svg_string(&self) -> String
pub fn to_svg_string(&self) -> String
Compact decimal for SVG attributes (same zenith-float decimal as layout golds).
Sourcepub fn from_ieee32_bits(bits: u32) -> Self
pub fn from_ieee32_bits(bits: u32) -> Self
Layout dimension from an IEEE-754 binary32 bit pattern (ttf-parser outline boundary).
Sourcepub fn to_ieee32_bits(&self) -> u32
pub fn to_ieee32_bits(&self) -> u32
Round to IEEE-754 binary32 bits for PNG / raster emission only.
Layout arithmetic stays in Dim. This is the pixel-coordinate terminal
permitted for SVG/PNG backends.
Sourcepub fn floor_to_u32(&self) -> Result<u32, Error>
pub fn floor_to_u32(&self) -> Result<u32, Error>
Largest u32 that is not greater than self. Negative and NaN fail.
Sourcepub fn ceil_to_u32(&self) -> Result<u32, Error>
pub fn ceil_to_u32(&self) -> Result<u32, Error>
Smallest u32 that is not less than self.
Trait Implementations§
impl Eq for Dim
Source§impl PartialOrd for Dim
impl PartialOrd for Dim
Auto Trait Implementations§
impl Freeze for Dim
impl RefUnwindSafe for Dim
impl Send for Dim
impl Sync for Dim
impl Unpin for Dim
impl UnsafeUnpin for Dim
impl UnwindSafe for Dim
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more