bidi-shaper
Version:
Logical→visual Unicode BiDi (UAX #9) reordering + Arabic contextual shaping for renderers outside the browser (PDF, canvas, WebGL, SVG, terminals, games). Zero dependencies.
28 lines (24 loc) • 1.24 kB
TypeScript
import { D as Direction, R as RenderOptions } from '../render-BhplWt64.js';
/**
* three.js adapter (`bidi-shaper/three`).
*
* TextGeometry, BitmapText implementations, and most SDF/MSDF text plugins
* place glyphs in string order with no shaping. Feed them
* {@link prepareText} output instead of the raw string.
*
* For multi-line labels use {@link prepareLines}: each line carries its
* resolved direction so you can set the anchor/pivot per line
* (e.g. troika-text `anchorX`, or aligning geometry bounding boxes).
*/
/** One display-ready line of a (possibly multi-line) label. */
interface PreparedTextLine {
/** Visual-order, shaped text — pass to TextGeometry/your text mesh. */
text: string;
/** Resolved direction; align RTL lines to the right edge of the label. */
direction: Direction;
}
/** Shape + reorder a single-line label for TextGeometry and friends. */
declare function prepareText(text: string, options?: RenderOptions): string;
/** Shape + reorder each line of a multi-line label, with per-line direction. */
declare function prepareLines(text: string, options?: RenderOptions): PreparedTextLine[];
export { Direction, type PreparedTextLine, RenderOptions, prepareLines, prepareText };