Files
NapCatQQ/.pnpm-store/v3/files/90/2fef04a279ebc9897022af7afdeb689fc5cf9d24de7f257ebdce94dc92a39df4fff43073e1959982c709c8aed298382a0a3852633ad3521a1f7cc1d7e04ae5
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

39 lines
972 B
Plaintext

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