UNPKG

unicode-shaper

Version:

Shape unicode text so that renderers like WebGL and WebGPU can properly display the glyphs.

64 lines 2.29 kB
/** A Definition tracks a cluster and its type */ export interface Definition<T> { /** cluster definition */ mType: T; /** reference to a slice of an original string */ code: number[]; } /** Cluster of definitions */ export interface Cluster<T> { /** array of definitions */ defs: Definition<T>[]; /** unicode whitespace (optional) */ whitespace?: number; } /** * Shared shaper - swaps characters * @param input - input unicode buffer * @param comparitor - characters to swap */ export declare function sharedShaper(input: number[], comparitor: number[]): void; /** * Build clusters * @param defs - array of definitions * @param cmp - comparator * @returns - array of clusters */ export declare function buildClusters<T>(defs: Definition<T>[], cmp: (t: T) => boolean): Cluster<T>[]; /** * Check if two types are the same or if the second type is J * @param a - first type * @param b - second type as a unicode * @param toMType - function to convert unicode to type * @returns - true if both types are the same */ export declare function mTypeIsSame<T>(a: T, b: number, toMType: (unicode: number) => T): boolean; /** * Convert input to clusters of definitions * @param input - input unicode buffer * @param toMType - function to convert unicode to type * @returns - array of clusters */ export declare function buildDefinitions<T>(input: number[], toMType: (unicode: number) => T): Definition<T>[]; /** BaseMType for shared shaper */ interface BaseMType { VPre: number; VAbv: number; VBlw: number; VPst: number; } /** * Once the Buginese shaping engine has analyzed the run into * clusters as described above, it performs any required reordering. * Pre-base vowels (VPre) are reordered to the start of the syllable * cluster. A sequence of multiple pre-base vowels is permitted. * Such sequences are moved as a block to the beginning of the cluster. * In the following example, the run of code points represents a * single cluster. * @param cluster - cluster of definitions * @param enumType - the enum to use * @returns - Returns the cluster sorted by dominant type */ export declare function commonGetSorted(cluster: Cluster<number>, enumType: BaseMType): number[]; export {}; //# sourceMappingURL=shared.d.ts.map