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.
1 lines • 2.09 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../../src/deno/index.ts"],"sourcesContent":["import { FontSplitProps } from '../interface.js';\nimport { getBinName, matchPlatform } from '../load.js';\nimport { createAPI } from '../createAPI.js';\nexport * from '../interface.js';\nexport * from '../createAPI.js';\n/** @ts-ignore */\nconst _Deno = Deno;\nlet binPath = _Deno.env.get('CN_FONT_SPLIT_BIN');\nif (!binPath) {\n binPath = new URL(\n '../' +\n getBinName(\n matchPlatform(process.platform, process.arch, () => false),\n ),\n import.meta.url,\n );\n // throw new Error('CN_FONT_SPLIT_BIN is undefined!');\n}\nconst dylib = _Deno.dlopen(binPath, {\n font_split: { parameters: ['buffer', 'usize', 'function'], result: 'void' },\n} as const);\nconst createCallback = (cb: (data: Uint8Array) => void) =>\n new _Deno.UnsafeCallback(\n {\n parameters: ['pointer', 'usize'],\n result: 'void',\n } as const,\n (success: any, length: number) => {\n let buffer = new _Deno.UnsafePointerView(success).getArrayBuffer(\n Number(length),\n );\n cb(new Uint8Array(buffer.slice()));\n },\n ).pointer;\n\nexport const fontSplit = createAPI(dylib.symbols.font_split, createCallback);\n"],"names":["_Deno","binPath","getBinName","matchPlatform","dylib","createCallback","cb","success","length","buffer","fontSplit","createAPI"],"mappings":";;;;AAMA,MAAMA,IAAQ;AACd,IAAIC,IAAUD,EAAM,IAAI,IAAI,mBAAmB;AAC1CC,MACDA,IAAU,IAAI;AAAA,EACV,QACIC;AAAA,IACIC,EAAc,QAAQ,UAAU,QAAQ,MAAM,MAAM,EAAK;AAAA,EAC7D;AAAA,EACJ,YAAY;AAChB;AAGJ,MAAMC,IAAQJ,EAAM,OAAOC,GAAS;AAAA,EAChC,YAAY,EAAE,YAAY,CAAC,UAAU,SAAS,UAAU,GAAG,QAAQ,OAAO;AAC9E,CAAU,GACJI,IAAiB,CAACC,MACpB,IAAIN,EAAM;AAAA,EACN;AAAA,IACI,YAAY,CAAC,WAAW,OAAO;AAAA,IAC/B,QAAQ;AAAA,EACZ;AAAA,EACA,CAACO,GAAcC,MAAmB;AAC9B,QAAIC,IAAS,IAAIT,EAAM,kBAAkBO,CAAO,EAAE;AAAA,MAC9C,OAAOC,CAAM;AAAA,IACjB;AACA,IAAAF,EAAG,IAAI,WAAWG,EAAO,MAAO,CAAA,CAAC;AAAA,EAAA;AAEzC,EAAE,SAEOC,IAAYC,EAAUP,EAAM,QAAQ,YAAYC,CAAc;"}