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
47 lines
1.4 KiB
Plaintext
47 lines
1.4 KiB
Plaintext
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = ttftowoff2;
|
|
exports.ttftowoff2async = ttftowoff2async;
|
|
var _index = _interopRequireDefault(require("../../woff2/index"));
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
/**
|
|
* @file ttf to woff2
|
|
* @author mengke01(kekee000@gmail.com)
|
|
*/
|
|
|
|
/**
|
|
* ttf格式转换成woff2字体格式
|
|
*
|
|
* @param {ArrayBuffer} ttfBuffer ttf缓冲数组
|
|
* @param {Object} options 选项
|
|
*
|
|
* @return {Promise.<ArrayBuffer>} woff格式byte流
|
|
*/
|
|
// eslint-disable-next-line no-unused-vars
|
|
function ttftowoff2(ttfBuffer) {
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
if (!_index.default.isInited()) {
|
|
throw new Error('use woff2.init() to init woff2 module!');
|
|
}
|
|
var result = _index.default.encode(ttfBuffer);
|
|
return result.buffer;
|
|
}
|
|
|
|
/**
|
|
* ttf格式转换成woff2字体格式
|
|
*
|
|
* @param {ArrayBuffer} ttfBuffer ttf缓冲数组
|
|
* @param {Object} options 选项
|
|
*
|
|
* @return {Promise.<ArrayBuffer>} woff格式byte流
|
|
*/
|
|
function ttftowoff2async(ttfBuffer) {
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
return _index.default.init(options.wasmUrl).then(function () {
|
|
var result = _index.default.encode(ttfBuffer);
|
|
return result.buffer;
|
|
});
|
|
} |