/// export type BufferFlag = 'BOT' | 'EOT' | 'PRESERVE_DEFAULT_IGNORABLES' | 'REMOVE_DEFAULT_IGNORABLES' | 'DO_NOT_INSERT_DOTTED_CIRCLE' | 'PRODUCE_UNSAFE_TO_CONCAT'; export declare namespace HB { type Handle = ReturnType; type Face = ReturnType['createFace']>; type Blob = ReturnType['createBlob']>; type Font = ReturnType['createFont']>; type Buffer = ReturnType['createBuffer']>; } /** * harfbuzz 的函数 * @message copied from https://github.com/harfbuzz/harfbuzzjs/blob/main/hbjs.js * @author refactor and modify by konghayao */ export declare function hbjs(instance: WebAssembly.Instance): { createSubset: (face: { ptr: any; upem: any; /** * Return the binary contents of an OpenType table. * @param {string} table Table name */ reference_table(table: string): Uint8Array; collectUnicodes(): Uint32Array; /** * Return letiation axis infos */ getAxisInfos(): Record; /** * Free the object. */ destroy(): void; free(): void; }, preserveNameIds?: number[], variationAxes?: Record) => { ptr: any; clearTableDrop(): void; adjustLayout(): void; deleteChar(arr: number[]): void; addChars(arr: (number | [number, number])[]): void; getResult(): number; runSubset(): number; destroy(): void; toBinary(): { destroy(): void; offset: any; subsetByteLength: any; blobPtr: any; data: () => Uint8Array; }; }; createBlob: (blob: Uint8Array) => { ptr: any; blobPtr: any; /** * Free the object. */ destroy(): void; free(): void; }; createFace: (blob: { ptr: any; blobPtr: any; /** * Free the object. */ destroy(): void; free(): void; }, index: number) => { ptr: any; upem: any; /** * Return the binary contents of an OpenType table. * @param {string} table Table name */ reference_table(table: string): Uint8Array; collectUnicodes(): Uint32Array; /** * Return letiation axis infos */ getAxisInfos(): Record; /** * Free the object. */ destroy(): void; free(): void; }; createFont: (face: { ptr: any; upem: any; /** * Return the binary contents of an OpenType table. * @param {string} table Table name */ reference_table(table: string): Uint8Array; collectUnicodes(): Uint32Array; /** * Return letiation axis infos */ getAxisInfos(): Record; /** * Free the object. */ destroy(): void; free(): void; }) => { ptr: any; glyphName: (glyphId: number) => string; glyphToPath: (glyphId: number) => string; /** * Return a glyph as a JSON path string * based on format described on https://svgwg.org/specs/paths/#InterfaceSVGPathSegment * @param {number} glyphId ID of the requested glyph in the font. **/ glyphToJson(glyphId: number): { type: string; values: number[]; }[]; /** * Set the font's scale factor, affecting the position values returned from * shaping. * @param {number} xScale Units to scale in the X dimension. * @param {number} yScale Units to scale in the Y dimension. **/ setScale(xScale: number, yScale: number): void; /** * Set the font's letiations. * @param {object} letiations Dictionary of letiations to set **/ setletiations(letiations: Record): void; /** * Free the object. */ destroy(): void; }; createBuffer: () => { ptr: any; /** * Add text to the buffer. * @param {string} text Text to be added to the buffer. **/ addText(text: string): void; /** * Set buffer script, language and direction. * * This needs to be done before shaping. **/ guessSegmentProperties(): any; /** * Set buffer direction explicitly. * @param {string} direction: One of "ltr", "rtl", "ttb" or "btt" */ setDirection(dir: 'ltr' | 'rtl' | 'ttb' | 'btt'): void; /** * Set buffer flags explicitly. * @param {string[]} flags: A list of strings which may be either: * "BOT" * "EOT" * "PRESERVE_DEFAULT_IGNORABLES" * "REMOVE_DEFAULT_IGNORABLES" * "DO_NOT_INSERT_DOTTED_CIRCLE" * "PRODUCE_UNSAFE_TO_CONCAT" */ setFlags(flags: BufferFlag[]): void; /** * Set buffer language explicitly. * @param {string} language: The buffer language */ setLanguage(language: string): void; /** * Set buffer script explicitly. * @param {string} script: The buffer script */ setScript(script: string): void; /** * Set the Harfbuzz clustering level. * * Affects the cluster values returned from shaping. * @param {number} level: Clustering level. See the Harfbuzz manual chapter * on Clusters. **/ setClusterLevel(level: number): void; /** * Return the buffer contents as a JSON object. * * After shaping, this function will return an array of glyph information * objects. Each object will have the following attributes: * * - g: The glyph ID * - cl: The cluster ID * - ax: Advance width (width to advance after this glyph is painted) * - ay: Advance height (height to advance after this glyph is painted) * - dx: X displacement (adjustment in X dimension when painting this glyph) * - dy: Y displacement (adjustment in Y dimension when painting this glyph) * - flags: Glyph flags like `HB_GLYPH_FLAG_UNSAFE_TO_BREAK` (0x1) **/ json(): { g: number; cl: number; ax: number; ay: number; dx: number; dy: number; flags: number; }[]; /** * Free the object. */ destroy(): void; }; shape: (font: HB.Font, buffer: HB.Buffer, features?: string) => void; shapeWithTrace: (font: { ptr: any; glyphName: (glyphId: number) => string; glyphToPath: (glyphId: number) => string; /** * Return a glyph as a JSON path string * based on format described on https://svgwg.org/specs/paths/#InterfaceSVGPathSegment * @param {number} glyphId ID of the requested glyph in the font. **/ glyphToJson(glyphId: number): { type: string; values: number[]; }[]; /** * Set the font's scale factor, affecting the position values returned from * shaping. * @param {number} xScale Units to scale in the X dimension. * @param {number} yScale Units to scale in the Y dimension. **/ setScale(xScale: number, yScale: number): void; /** * Set the font's letiations. * @param {object} letiations Dictionary of letiations to set **/ setletiations(letiations: Record): void; /** * Free the object. */ destroy(): void; }, buffer: { ptr: any; glyphName: (glyphId: number) => string; glyphToPath: (glyphId: number) => string; /** * Return a glyph as a JSON path string * based on format described on https://svgwg.org/specs/paths/#InterfaceSVGPathSegment * @param {number} glyphId ID of the requested glyph in the font. **/ glyphToJson(glyphId: number): { type: string; values: number[]; }[]; /** * Set the font's scale factor, affecting the position values returned from * shaping. * @param {number} xScale Units to scale in the X dimension. * @param {number} yScale Units to scale in the Y dimension. **/ setScale(xScale: number, yScale: number): void; /** * Set the font's letiations. * @param {object} letiations Dictionary of letiations to set **/ setletiations(letiations: Record): void; /** * Free the object. */ destroy(): void; }, features: string, stop_at: number, stop_phase: number) => any; exports: any; heapu8: Uint8Array; heapf32: Float32Array; heapi32: Int32Array; heapu32: Uint32Array; typedArrayFromSet: { (setPtr: number, arrayClass: typeof Float32Array): InstanceType; (setPtr: number, arrayClass: typeof Int32Array): InstanceType; (setPtr: number, arrayClass: typeof Uint32Array): InstanceType; (setPtr: number, arrayClass: typeof Uint8Array): InstanceType; }; collectUnicodes: (ptr?: number) => Uint32Array; };