UNPKG

cn-font-split

Version:

划时代的字体切割工具,CJK与任何字符!支持 otf、ttf、woff2 字体多线程切割,完美地细颗粒度地进行包大小控制。A revolutionary font subetter that supports CJK and any characters! It enables multi-threaded subset of otf, ttf, and woff2 fonts, allowing for precise control over package size.

27 lines (26 loc) 987 B
import { getBinName as e, matchPlatform as t } from "../load.mjs"; import { isMusl as n } from "../node/isMusl.mjs"; import { api_interface as r } from "../gen/index.mjs"; import { decodeReporter as i } from "../decodeReporter.mjs"; import { createAPI as a } from "../createAPI.mjs"; import o from "path"; import { FFIType as s, JSCallback as c, dlopen as l, ptr as u, toArrayBuffer as d } from "bun:ffi"; //#region src/bun/index.ts var f = process.env.CN_FONT_SPLIT_BIN; f ||= o.resolve(__dirname, "../" + e(t(process.platform, process.arch, n))); var { symbols: { font_split: p }, close: m } = l(f, { font_split: { args: [ s.ptr, s.usize, s.callback ], returns: s.void } }), h = a((e, t, n) => p(u(e), t, n), (e) => new c((t, n) => { e(new Uint8Array(d(t, 0, Number(n)).slice(), 0, Number(n))); }, { returns: s.void, args: [s.ptr, s.usize] }).ptr); //#endregion export { a as createAPI, i as decodeReporter, h as fontSplit, r as proto }; //# sourceMappingURL=index.mjs.map