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.
42 lines (41 loc) • 1.04 kB
JavaScript
import { dlopen as p, FFIType as r, JSCallback as i, ptr as m, toArrayBuffer as c } from "bun:ffi";
import n from "path";
import { getBinName as l, matchPlatform as f } from "../load.mjs";
import { isMusl as u } from "../node/isMusl.mjs";
import { createAPI as _ } from "../createAPI.mjs";
import { decodeReporter as B } from "../decodeReporter.mjs";
import { api_interface as F } from "../gen/index.mjs";
let s = process.env.CN_FONT_SPLIT_BIN;
s || (s = n.resolve(
__dirname,
"../" + l(f(process.platform, process.arch, u))
));
const {
symbols: { font_split: b },
close: h
} = p(s, {
font_split: {
args: [r.ptr, r.usize, r.callback],
returns: r.void
}
}), d = (o) => new i(
(e, t) => {
const a = new Uint8Array(
c(e, 0, Number(t)).slice(),
0,
Number(t)
);
o(a);
},
{
returns: r.void,
args: [r.ptr, r.usize]
}
).ptr, k = _((o, e, t) => b(m(o), e, t), d);
export {
_ as createAPI,
B as decodeReporter,
k as fontSplit,
F as proto
};
//# sourceMappingURL=index.mjs.map