unicode-shaper
Version:
Shape unicode text so that renderers like WebGL and WebGPU can properly display the glyphs.
20 lines • 689 B
JavaScript
import { DEFAULT_OPTIONS, shapeUnicode } from './shape/index.js';
export * from './shape/index.js';
export * from './textShaperWasm.js';
export * from './ubidi/index.js';
/**
* Converts a string into a shaped string
* @param str - input string
* @param options - shaping options
* @returns - shaped string
*/
export function shapeString(str, options = DEFAULT_OPTIONS) {
if (str.length === 0)
return str;
const unicodes = new Array(str.length);
for (let i = 0, len = str.length; i < len; i++)
unicodes[i] = str.charCodeAt(i);
const result = shapeUnicode(unicodes, options);
return String.fromCharCode(...result);
}
//# sourceMappingURL=index.js.map