/** * OpenType Text Shaping Engine * * Provides basic text shaping for complex scripts without external dependencies. * Covers Arabic joining, BiDi reordering, and basic Indic/Thai features. * * This is not a full HarfBuzz replacement — it handles the most common shaping * requirements for document layout and rendering: * - Arabic contextual joining (Initial/Medial/Final/Isolated forms) * - Unicode Bidirectional Algorithm (UAX #9) simplified implementation * - Basic Indic vowel reordering (Devanagari, Bengali, Tamil, etc.) * - Thai/Lao mark positioning hints * * @stability experimental */ /** Script classification for a text run. */ export type ScriptType = "latin" | "arabic" | "hebrew" | "devanagari" | "bengali" | "tamil" | "thai" | "lao" | "cjk" | "hangul" | "other"; /** BiDi direction for a text segment. */ export type BiDiDirection = "ltr" | "rtl"; /** A shaped glyph cluster — the output of shaping. */ export interface ShapedCluster { /** The original characters in this cluster. */ readonly chars: string; /** The visual form (after joining/reordering). */ readonly visual: string; /** Advance width multiplier (1.0 = normal, 0 = zero-width). */ readonly advanceMultiplier: number; /** Script classification. */ readonly script: ScriptType; /** BiDi direction. */ readonly direction: BiDiDirection; } /** Shaping options. */ export interface ShapingOptions { /** Base paragraph direction. Default: "ltr". */ readonly direction?: BiDiDirection; /** Enable Arabic joining. Default: true. */ readonly arabicJoining?: boolean; /** Enable BiDi reordering. Default: true. */ readonly bidiReorder?: boolean; } /** * Shape a text string for complex script rendering. * Returns an array of shaped clusters in visual order. * * @param text - The input text in logical order. * @param options - Shaping options. * @returns Array of shaped clusters. */ export declare function shapeText(text: string, options?: ShapingOptions): ShapedCluster[]; /** * Detect the dominant script of a text string. */ export declare function detectScript(text: string): ScriptType; /** * Determine the BiDi direction of a text based on its first strong character. */ export declare function detectDirection(text: string): BiDiDirection;