Skip to main content

TextShaper

Trait TextShaper 

Source
pub trait TextShaper {
    // Required method
    fn shape(
        &self,
        text: &str,
        script: Script,
        direction: RunDirection,
        features: &FontFeatures,
    ) -> ShapedRun;
}
Expand description

Abstract text shaping backend.

Implementations convert a Unicode text string into positioned glyphs according to the rules of the specified script, direction, and font features.

The trait is object-safe to allow dynamic dispatch between backends (e.g., terminal noop vs. web rustybuzz).

Required Methods§

Source

fn shape( &self, text: &str, script: Script, direction: RunDirection, features: &FontFeatures, ) -> ShapedRun

Shape a text run into positioned glyphs.

§Parameters
  • text — The text to shape (UTF-8, from a single TextRun).
  • script — The resolved Unicode script.
  • direction — LTR or RTL text direction.
  • features — OpenType features to apply.
§Returns

A ShapedRun containing positioned glyphs in visual order.

Implementors§