pub struct Scale {
x_mult: i64,
y_mult: i64,
x_multf: f32,
y_multf: f32,
}Expand description
Converts font units to the configured font scale.
The conversion uses the scale set on ShaperFont
and follows HarfBuzz’s rounding rules for glyph metrics and shaping.
Fields§
§x_mult: i64§y_mult: i64§x_multf: f32§y_multf: f32Implementations§
Source§impl Scale
impl Scale
Sourcepub fn new(scale: Option<(i32, i32)>, upem: i32) -> Self
pub fn new(scale: Option<(i32, i32)>, upem: i32) -> Self
Creates a conversion from font units to the requested scale.
Returns an identity conversion if scale is None or upem is zero.
Sourcepub(crate) fn scale_x_f(&self, x: f32) -> i32
pub(crate) fn scale_x_f(&self, x: f32) -> i32
Scales a fractional (font-unit) value, matching HarfBuzz’s em_scalef
(roundf(v * scale / upem)).
pub(crate) fn scale_y_f(&self, y: f32) -> i32
Sourcepub(crate) fn clamp_x_advance(&self, advance: i32) -> i32
pub(crate) fn clamp_x_advance(&self, advance: i32) -> i32
Clamps a scaled advance to the sign of its scale. This applies the unsigned font-unit bound while preserving deliberately negative scales.
pub(crate) fn clamp_y_advance(&self, advance: i32) -> i32
fn clamp_advance(advance: i32, scale: f32) -> i32
Sourcepub fn scale_extents(&self, extents: GlyphExtents) -> GlyphExtents
pub fn scale_extents(&self, extents: GlyphExtents) -> GlyphExtents
Scales glyph extents using HarfBuzz’s corner rounding.
Floors the near corners and ceils the far corners before calculating width and height.
fn mult_from_scale(scale: i32, upem: i32) -> i64
fn scale_by_mult(value: i32, mult: i64) -> i32
Trait Implementations§
impl Copy for Scale
Source§impl Scale for Scale
impl Scale for Scale
Source§fn scale_glyph_extents(
&self,
extents: GlyphExtents<F48Dot16>,
) -> GlyphExtents<i32>
fn scale_glyph_extents( &self, extents: GlyphExtents<F48Dot16>, ) -> GlyphExtents<i32>
Scales where a glyph’s ink sits. Read more
Source§fn scale_rect(&self, bounds: BoundingBox<F48Dot16>) -> BoundingBox<i32>
fn scale_rect(&self, bounds: BoundingBox<F48Dot16>) -> BoundingBox<i32>
Scales a region given by its corners. Read more
Auto Trait Implementations§
impl Freeze for Scale
impl RefUnwindSafe for Scale
impl Send for Scale
impl Sync for Scale
impl Unpin for Scale
impl UnsafeUnpin for Scale
impl UnwindSafe for Scale
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