Skip to main content

SystemFontProvider

Trait SystemFontProvider 

Source
pub trait SystemFontProvider {
    // Required methods
    fn font_info(&self) -> SystemFontInfo;
    fn rasterize(&self, key: GlyphKey) -> Option<RasterizedGlyph>;

    // Provided methods
    fn rasterize_batch(&self, keys: &[GlyphKey]) -> Vec<Option<RasterizedGlyph>> { ... }
    fn rasterize_into(
        &self,
        key: GlyphKey,
        dst: &mut Vec<u8>,
    ) -> Option<(u32, u32, u32)> { ... }
}
Expand description

Abstraction for native OS and deterministic glyph rasterization providers.

Required Methods§

Source

fn font_info(&self) -> SystemFontInfo

Returns metadata describing this font provider’s active backend and capabilities.

§Arguments
  • &Self - Font provider reference.
§Returns
  • SystemFontInfo - Provider capabilities and family metadata.
Source

fn rasterize(&self, key: GlyphKey) -> Option<RasterizedGlyph>

Rasterizes a quantized GlyphKey into an alpha8 coverage bitmap.

§Arguments
  • &Self - Font provider reference.
  • GlyphKey - Quantized character, font size, bold flag, and family.
§Returns
  • Option<RasterizedGlyph> - Rasterized glyph bitmap if supported by this provider.

Provided Methods§

Source

fn rasterize_batch(&self, keys: &[GlyphKey]) -> Vec<Option<RasterizedGlyph>>

Rasterizes a batch of missing GlyphKey entries in a single provider pass to amortize OS/Web readbacks.

§Arguments
  • &Self - Font provider reference.
  • &[GlyphKey] - Slice of missing glyph keys to rasterize.
§Returns
  • Vec<Option<RasterizedGlyph>> - Rasterized glyph results aligned 1:1 with keys.
Source

fn rasterize_into( &self, key: GlyphKey, dst: &mut Vec<u8>, ) -> Option<(u32, u32, u32)>

Rasterizes key directly into a caller-owned reusable dst alpha8 staging buffer without allocating a fresh bitmap vector.

§Arguments
  • &Self - Font provider reference.
  • GlyphKey - Quantized glyph descriptor.
  • &mut Vec<u8> - Reusable destination staging buffer cleared and overwritten with row-major alpha8 pixels.
§Returns
  • Option<(u32, u32, u32)> - Tuple (width, height, advance) when rasterization succeeded.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl SystemFontProvider for NativeSystemFont

SystemFontProvider implementation delegating to OS native APIs with batched and zero-alloc staging paths.