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.

43 lines (42 loc) 1.38 kB
import m, { dirname as p } from "path"; import { getBinName as n, matchPlatform as s } from "../load.mjs"; import { isMusl as f } from "./isMusl.mjs"; import { createAPI as c } from "../createAPI.mjs"; import "../node_modules/.pnpm/@xan105_ffi@1.3.0_koffi@2.10.0/node_modules/@xan105/ffi/lib/koffi/index.mjs"; import o from "koffi"; import { fileURLToPath as l } from "url"; import { dlopen as d } from "../node_modules/.pnpm/@xan105_ffi@1.3.0_koffi@2.10.0/node_modules/@xan105/ffi/lib/koffi/open.mjs"; import { Callback as _ } from "../node_modules/.pnpm/@xan105_ffi@1.3.0_koffi@2.10.0/node_modules/@xan105/ffi/lib/koffi/helper.mjs"; import { decodeReporter as L } from "../decodeReporter.mjs"; import { api_interface as S } from "../gen/index.mjs"; const u = l(import.meta.url), h = p(u); let r = process.env.CN_FONT_SPLIT_BIN; r || (r = m.resolve( h, "../" + n(s(process.platform, process.arch, f)) )); const P = d(r, { font_split: { parameters: ["pointer", "usize", "function"], result: "void" } }), b = (t) => new _( { parameters: ["pointer", "usize"], result: "void" }, (e, i) => { const a = o.decode( e, o.array("uint8_t", i, "Array") ); t(new Uint8Array(a)); } ).pointer, w = c(P.font_split, b); export { c as createAPI, L as decodeReporter, w as fontSplit, S as proto }; //# sourceMappingURL=index.mjs.map