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
66 lines
3.0 KiB
Plaintext
66 lines
3.0 KiB
Plaintext
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = otf2ttfobject;
|
|
var _error = _interopRequireDefault(require("./error"));
|
|
var _otfreader = _interopRequireDefault(require("./otfreader"));
|
|
var _otfContours2ttfContours = _interopRequireDefault(require("./util/otfContours2ttfContours"));
|
|
var _computeBoundingBox = require("../graphics/computeBoundingBox");
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /**
|
|
* @file otf格式转ttf格式对象
|
|
* @author mengke01(kekee000@gmail.com)
|
|
*/
|
|
/**
|
|
* otf格式转ttf格式对象
|
|
*
|
|
* @param {ArrayBuffer|otfObject} otfBuffer 原始数据或者解析后的otf数据
|
|
* @param {Object} options 参数
|
|
* @return {Object} ttfObject对象
|
|
*/
|
|
function otf2ttfobject(otfBuffer, options) {
|
|
var otfObject;
|
|
if (otfBuffer instanceof ArrayBuffer) {
|
|
var otfReader = new _otfreader.default(options);
|
|
otfObject = otfReader.read(otfBuffer);
|
|
otfReader.dispose();
|
|
} else if (otfBuffer.head && otfBuffer.glyf && otfBuffer.cmap) {
|
|
otfObject = otfBuffer;
|
|
} else {
|
|
_error.default.raise(10111);
|
|
}
|
|
|
|
// 转换otf轮廓
|
|
otfObject.glyf.forEach(function (g) {
|
|
g.contours = (0, _otfContours2ttfContours.default)(g.contours);
|
|
var box = _computeBoundingBox.computePathBox.apply(void 0, _toConsumableArray(g.contours));
|
|
if (box) {
|
|
g.xMin = box.x;
|
|
g.xMax = box.x + box.width;
|
|
g.yMin = box.y;
|
|
g.yMax = box.y + box.height;
|
|
g.leftSideBearing = g.xMin;
|
|
} else {
|
|
g.xMin = 0;
|
|
g.xMax = 0;
|
|
g.yMin = 0;
|
|
g.yMax = 0;
|
|
g.leftSideBearing = 0;
|
|
}
|
|
});
|
|
otfObject.version = 0x1;
|
|
|
|
// 修改maxp相关配置
|
|
otfObject.maxp.version = 1.0;
|
|
otfObject.maxp.maxZones = otfObject.maxp.maxTwilightPoints ? 2 : 1;
|
|
delete otfObject.CFF;
|
|
delete otfObject.VORG;
|
|
return otfObject;
|
|
} |