Skip to main content

PlatformTextSystem

Trait PlatformTextSystem 

Source
pub trait PlatformTextSystem: Send + Sync {
    // Required methods
    fn add_fonts(&self, fonts: Vec<Cow<'static, [u8]>>) -> Result<(), Error>;
    fn all_font_names(&self) -> Vec<String>;
    fn font_id(&self, descriptor: &Font) -> Result<FontId, Error>;
    fn font_metrics(&self, font_id: FontId) -> FontMetrics;
    fn typographic_bounds(
        &self,
        font_id: FontId,
        glyph_id: GlyphId,
    ) -> Result<Bounds<f32>, Error>;
    fn advance(
        &self,
        font_id: FontId,
        glyph_id: GlyphId,
    ) -> Result<Size<f32>, Error>;
    fn glyph_for_char(&self, font_id: FontId, ch: char) -> Option<GlyphId>;
    fn glyph_raster_bounds(
        &self,
        params: &RenderGlyphParams,
    ) -> Result<Bounds<DevicePixels>, Error>;
    fn rasterize_glyph(
        &self,
        params: &RenderGlyphParams,
        raster_bounds: Bounds<DevicePixels>,
    ) -> Result<(Size<DevicePixels>, Vec<u8>), Error>;
    fn layout_line(
        &self,
        text: &str,
        font_size: Pixels,
        runs: &[FontRun],
    ) -> LineLayout;
}
Expand description

Font discovery, shaping, and glyph rasterization supplied by a platform or test.

Required Methods§

Source

fn add_fonts(&self, fonts: Vec<Cow<'static, [u8]>>) -> Result<(), Error>

Register additional font data.

Source

fn all_font_names(&self) -> Vec<String>

List available font families.

Source

fn font_id(&self, descriptor: &Font) -> Result<FontId, Error>

Resolve a font descriptor.

Source

fn font_metrics(&self, font_id: FontId) -> FontMetrics

Return metrics in font units.

Source

fn typographic_bounds( &self, font_id: FontId, glyph_id: GlyphId, ) -> Result<Bounds<f32>, Error>

Return glyph bounds in font units.

Source

fn advance( &self, font_id: FontId, glyph_id: GlyphId, ) -> Result<Size<f32>, Error>

Return glyph advance in font units.

Source

fn glyph_for_char(&self, font_id: FontId, ch: char) -> Option<GlyphId>

Find a glyph for a character.

Source

fn glyph_raster_bounds( &self, params: &RenderGlyphParams, ) -> Result<Bounds<DevicePixels>, Error>

Calculate device-pixel bounds for rasterization.

Source

fn rasterize_glyph( &self, params: &RenderGlyphParams, raster_bounds: Bounds<DevicePixels>, ) -> Result<(Size<DevicePixels>, Vec<u8>), Error>

Rasterize a glyph inside the supplied bounds.

Source

fn layout_line( &self, text: &str, font_size: Pixels, runs: &[FontRun], ) -> LineLayout

Shape a line using byte-indexed font runs.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§