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§
Sourcefn add_fonts(&self, fonts: Vec<Cow<'static, [u8]>>) -> Result<(), Error>
fn add_fonts(&self, fonts: Vec<Cow<'static, [u8]>>) -> Result<(), Error>
Register additional font data.
Sourcefn all_font_names(&self) -> Vec<String>
fn all_font_names(&self) -> Vec<String>
List available font families.
Sourcefn font_metrics(&self, font_id: FontId) -> FontMetrics
fn font_metrics(&self, font_id: FontId) -> FontMetrics
Return metrics in font units.
Sourcefn typographic_bounds(
&self,
font_id: FontId,
glyph_id: GlyphId,
) -> Result<Bounds<f32>, Error>
fn typographic_bounds( &self, font_id: FontId, glyph_id: GlyphId, ) -> Result<Bounds<f32>, Error>
Return glyph bounds in font units.
Sourcefn advance(
&self,
font_id: FontId,
glyph_id: GlyphId,
) -> Result<Size<f32>, Error>
fn advance( &self, font_id: FontId, glyph_id: GlyphId, ) -> Result<Size<f32>, Error>
Return glyph advance in font units.
Sourcefn glyph_for_char(&self, font_id: FontId, ch: char) -> Option<GlyphId>
fn glyph_for_char(&self, font_id: FontId, ch: char) -> Option<GlyphId>
Find a glyph for a character.
Sourcefn glyph_raster_bounds(
&self,
params: &RenderGlyphParams,
) -> Result<Bounds<DevicePixels>, Error>
fn glyph_raster_bounds( &self, params: &RenderGlyphParams, ) -> Result<Bounds<DevicePixels>, Error>
Calculate device-pixel bounds for rasterization.
Sourcefn rasterize_glyph(
&self,
params: &RenderGlyphParams,
raster_bounds: Bounds<DevicePixels>,
) -> Result<(Size<DevicePixels>, Vec<u8>), Error>
fn rasterize_glyph( &self, params: &RenderGlyphParams, raster_bounds: Bounds<DevicePixels>, ) -> Result<(Size<DevicePixels>, Vec<u8>), Error>
Rasterize a glyph inside the supplied bounds.
Sourcefn layout_line(
&self,
text: &str,
font_size: Pixels,
runs: &[FontRun],
) -> LineLayout
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".