UNPKG

@aurigma/text-whizz

Version:

This is a part of a text engine of Customer's Canvas/Design Atoms. Don't use it directly.

26 lines (18 loc) 809 B
import * as textWhizz from "@aurigma/text-whizz/TextWhizzJS"; export namespace factory { export function createFontRegistry (dpi: number) { let fr = new textWhizz.FontRegistry(dpi); const mixin = { addFromArray(byteArray) { let numBytes = byteArray.length * byteArray.BYTES_PER_ELEMENT; let ptr = textWhizz._malloc(numBytes); let heapBytes = new Uint8Array(textWhizz.HEAPU8.buffer, ptr, numBytes); heapBytes.set(new Uint8Array(byteArray)); let fontName = fr.add(heapBytes.byteOffset, heapBytes.length); textWhizz._free(ptr); return fontName; } }; return Object.assign(fr, mixin); }; }