Files
NapCatQQ/.pnpm-store/v3/files/42/f8509ce50c27a5bdd616f8c7178d6909809e2cbb3607a3fedc31405c7f9d24c59ed99690233706d1630adde1ed5ec28096017443162592fb85ac9b5e1b42a5
T
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

40 lines
971 B
Plaintext

/**
* @file ttf to woff2
* @author mengke01(kekee000@gmail.com)
*/
import woff2 from '../../woff2/index';
/**
* ttf格式转换成woff2字体格式
*
* @param {ArrayBuffer} ttfBuffer ttf缓冲数组
* @param {Object} options 选项
*
* @return {Promise.<ArrayBuffer>} woff格式byte流
*/
// eslint-disable-next-line no-unused-vars
export default function ttftowoff2(ttfBuffer, options = {}) {
if (!woff2.isInited()) {
throw new Error('use woff2.init() to init woff2 module!');
}
const result = woff2.encode(ttfBuffer);
return result.buffer;
}
/**
* ttf格式转换成woff2字体格式
*
* @param {ArrayBuffer} ttfBuffer ttf缓冲数组
* @param {Object} options 选项
*
* @return {Promise.<ArrayBuffer>} woff格式byte流
*/
export function ttftowoff2async(ttfBuffer, options = {}) {
return woff2.init(options.wasmUrl).then(() => {
const result = woff2.encode(ttfBuffer);
return result.buffer;
});
}