Skip to main content

MsdfAtlas

Struct MsdfAtlas 

Source
pub struct MsdfAtlas {
    pub width: u32,
    pub height: u32,
    pub texture: Vec<u8>,
    pub uv_map: HashMap<u16, UvRect>,
}
Expand description

A packed atlas of MSDF glyph tiles, ready for GPU upload.

The atlas texture is stored as an RGB byte slice (texture), three bytes per pixel. Each pixel encodes signed distances in the R, G, and B channels for the corresponding colored edge of the glyph outline.

Fields§

§width: u32

Atlas width in pixels.

§height: u32

Atlas height in pixels.

§texture: Vec<u8>

Raw RGB texture data: width * height * 3 bytes.

§uv_map: HashMap<u16, UvRect>

UV coordinates for each glyph ID within the atlas.

Implementations§

Source§

impl MsdfAtlas

Source

pub fn pack(tiles: &[MsdfTile], atlas_size: u32) -> Self

Pack a set of MSDF tiles into a fixed-size atlas texture.

Uses the same left-to-right shelf-packing algorithm as SdfAtlas, adapted for 3-bytes-per-pixel (RGB) tiles.

If tiles is empty, returns a minimal 1×1 atlas.

Source

pub fn export_png(&self, path: &Path) -> Result<(), SdfError>

Export the atlas texture as a PNG file for visualization.

The texture is stored as RGB (3 bytes per pixel). Each channel encodes a signed distance for the corresponding colored edge of the glyph outline.

Source§

impl MsdfAtlas

Source

pub fn to_gpu_descriptor(&self) -> GpuAtlasDescriptor

Produce a GPU-ready descriptor for this MSDF atlas.

Returns GpuAtlasFormat::Rgb8Unorm (3 bytes per pixel) with the raw RGB texture data. glyph_metrics is empty for the same reason as for SdfAtlas::to_gpu_descriptor.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.