skia
    Preparing search index...

    Interface Shaper

    A Shaper wraps SkShaper and provides text shaping — converting UTF-8 strings into positioned glyph runs (SkTextBlob) ready for drawing on a Canvas. Requires fonts to be compiled in (not available in no-font builds).

    interface Shaper {
        _type: "Shaper";
        delete(): void;
        deleteLater(): void;
        getEndPoint(
            text: string,
            font: Font,
            leftToRight: boolean,
            width: number,
            offsetX: number,
            offsetY: number,
        ): Float32Array;
        isAliasOf(other: any): boolean;
        isDeleted(): boolean;
        shapeTextToBlob(
            text: string,
            font: Font,
            leftToRight: boolean,
            width: number,
            offsetX: number,
            offsetY: number,
        ): TextBlob | null;
        shapeTextToBlobWithFeatures(
            text: string,
            font: Font,
            fontMgr: FontMgr | null,
            leftToRight: boolean,
            width: number,
            offsetX: number,
            offsetY: number,
            features: OpenTypeFeature[],
        ): TextBlob | null;
        shapeTextToBlobWithFontMgr(
            text: string,
            font: Font,
            fontMgr: FontMgr,
            leftToRight: boolean,
            width: number,
            offsetX: number,
            offsetY: number,
        ): TextBlob | null;
    }

    Hierarchy (View Summary)

    Index

    Properties

    _type: "Shaper"

    Methods

    • Shapes text and returns the final pen position as [x, y]. Useful for chaining multiple shaped runs (e.g. mixed-style text on one line) where you need to know where the next run should start.

      Parameters

      • text: string

        UTF-8 text to shape.

      • font: Font

        Base font.

      • leftToRight: boolean

        true for LTR text, false for RTL.

      • width: number

        Line-wrap width in pixels.

      • offsetX: number

        Starting X offset.

      • offsetY: number

        Starting Y offset (baseline).

      Returns Float32Array

      Float32Array of length 2: [endX, endY].

    • Shapes the given UTF-8 text with the provided font and returns an SkTextBlob. Returns null if shaping produces no glyphs (e.g. empty string or font has no matching glyphs).

      Parameters

      • text: string

        UTF-8 text to shape.

      • font: Font

        Base font (size, typeface, etc.).

      • leftToRight: boolean

        true for LTR text, false for RTL.

      • width: number

        Line-wrap width in pixels. Pass a very large value (e.g. Infinity is clamped — use 1e9) to disable wrapping.

      • offsetX: number

        X offset embedded into all glyph positions.

      • offsetY: number

        Y offset (baseline) embedded into all glyph positions.

      Returns TextBlob | null

    • Full-control shaping: combines font fallback (via fontMgr) with explicit OpenType features. Pass null for fontMgr to use only the primary font.

      Features are applied per UTF-8 byte range [start, end). To apply a feature to the entire string use start=0 and end equal to the byte length of the text.

      Parameters

      • text: string

        UTF-8 text to shape.

      • font: Font

        Primary font.

      • fontMgr: FontMgr | null

        Font manager for fallback (may be null).

      • leftToRight: boolean

        true for LTR, false for RTL.

      • width: number

        Line-wrap width in pixels.

      • offsetX: number

        X offset embedded into all glyph positions.

      • offsetY: number

        Y offset (baseline) embedded into all glyph positions.

      • features: OpenTypeFeature[]

        OpenType features to apply.

      Returns TextBlob | null

    • Like shapeTextToBlob but uses fontMgr for automatic per-run font fallback. When a glyph is not found in font, fontMgr is searched for a face that covers the missing codepoints. Essential for correct rendering of mixed-script or multilingual text.

      Parameters

      • text: string

        UTF-8 text to shape.

      • font: Font

        Primary font; fallback fonts are sourced from fontMgr.

      • fontMgr: FontMgr

        Font manager used to resolve missing glyphs (e.g. a TypefaceFontProvider with multiple faces registered).

      • leftToRight: boolean

        true for LTR text, false for RTL.

      • width: number

        Line-wrap width in pixels.

      • offsetX: number

        X offset embedded into all glyph positions.

      • offsetY: number

        Y offset (baseline) embedded into all glyph positions.

      Returns TextBlob | null