Skip to main content

Shaper

Trait Shaper 

Source
pub trait Shaper: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn shape(
        &self,
        text: &str,
        font: Arc<dyn FontRef>,
        params: &ShapingParams,
    ) -> Result<ShapingResult>;

    // Provided methods
    fn supports_script(&self, _script: &str) -> bool { ... }
    fn clear_cache(&self) { ... }
}
Expand description

Where characters learn their positions

Text shaping is where script rules, font features, and character clusters collide to produce perfectly positioned glyphs ready for rendering.

Required Methods§

Source

fn name(&self) -> &'static str

Identify yourself in logs and error messages

Source

fn shape( &self, text: &str, font: Arc<dyn FontRef>, params: &ShapingParams, ) -> Result<ShapingResult>

Transform characters into positioned glyphs

Provided Methods§

Source

fn supports_script(&self, _script: &str) -> bool

Can you handle this script?

Returns false by default - implementations should explicitly declare support.

Source

fn clear_cache(&self)

Flush any cached shaping data

Implementors§