pub struct SdfTile {
pub glyph_id: u16,
pub width: u32,
pub height: u32,
pub data: Vec<u8>,
pub bearing_x: i32,
pub bearing_y: i32,
pub advance_x: f32,
}Expand description
A single SDF glyph tile produced by the SDF pipeline.
Fields§
§glyph_id: u16Glyph ID within the font.
width: u32Tile width in pixels.
height: u32Tile height in pixels.
data: Vec<u8>SDF pixel data (width × height bytes, values 0–255).
bearing_x: i32Left bearing in pixels (signed).
bearing_y: i32Top bearing in pixels (signed).
advance_x: f32Horizontal advance in pixels.
Implementations§
Source§impl SdfTile
impl SdfTile
Sourcepub fn from_coverage(
glyph_id: u16,
coverage: &[f32],
width: usize,
height: usize,
spread: f32,
bearing_x: i32,
bearing_y: i32,
advance_x: f32,
) -> Result<Self, SdfError>
pub fn from_coverage( glyph_id: u16, coverage: &[f32], width: usize, height: usize, spread: f32, bearing_x: i32, bearing_y: i32, advance_x: f32, ) -> Result<Self, SdfError>
Create an SDF tile from a pre-rasterized floating-point coverage bitmap.
§Arguments
glyph_id— glyph index within the font.coverage— greyscale coverage values,width × height, values in[0, 1].width,height— bitmap dimensions (must be non-zero).spread— maximum SDF distance in pixels; maps ±spread to [0, 255].bearing_x,bearing_y— glyph bearing in pixels (signed).advance_x— horizontal advance in pixels.
§Errors
Returns SdfError::ZeroSize when width or height is zero.
Returns SdfError::InvalidInput when coverage.len() != width * height.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SdfTile
impl RefUnwindSafe for SdfTile
impl Send for SdfTile
impl Sync for SdfTile
impl Unpin for SdfTile
impl UnsafeUnpin for SdfTile
impl UnwindSafe for SdfTile
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
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>
Converts
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>
Converts
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