Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onSuccess(binaryData) {
let ttfReader = new TTFReader({
// hinting: true,
subset: [65, 0x160, 0x161, 0x162]
});
let ttfData = ttfReader.read(binaryData);
console.log(ttfData);
},
onError() {
describe('读ttf hinting数据', function () {
let fontObject = new TTFReader({
hinting: true
}).read(readData('baiduHealth-hinting.ttf'));
it('test read hinting', function () {
assert.equal(fontObject.cvt.length, 24);
assert.equal(fontObject.fpgm.length, 371);
assert.equal(fontObject.prep.length, 204);
assert.equal(fontObject.gasp.length, 8);
assert.equal(fontObject.GPOS.length, 18);
fontObject.kern && assert.equal(fontObject.kern.length, 8);
});
});
describe('写ttf数据', function () {
let fontObject = new TTFReader().read(readData('baiduHealth.ttf'));
it('test write ttf', function () {
let buffer = new TTFWriter().write(fontObject);
assert.ok(buffer.byteLength > 1000);
assert.ok(buffer.byteLength < 10000);
let ttf = new TTFReader().read(buffer);
assert.equal(ttf.version, 1);
assert.equal(ttf.head.magickNumber, 1594834165);
assert.equal(ttf.head.unitsPerEm, 512);
assert.equal(ttf.post.format, 2);
assert.equal(ttf.post.underlinePosition, 0);
assert.equal(ttf.post.underlineThickness, 0);
onSuccess(buffer) {
let ttfBuffer = woff2ttf(buffer, {
inflate
});
let saveBtn = $('.saveas');
saveBtn.attr('href', ttf2base64(ttfBuffer));
saveBtn.attr('download', 'save.woff');
let ttfReader = new TTFReader();
let ttfData = ttfReader.read(ttfBuffer);
console.log(ttfData);
},
onError() {
$.getJSON('./data/baiduHealth.json', function (ttf) {
let reader = new TTFReader();
let writer = new TTFWriter();
let buffer = writer.write(ttf);
let ttfData = reader.read(buffer);
console.log(ttfData);
let base64str = ttf2base64(buffer);
let saveBtn = $('.saveas');
saveBtn.attr('href', base64str);
saveBtn.attr('download', 'save.ttf');
});
}
onSuccess(binaryData) {
setFont(binaryData);
let ttfReander = new TTFReader();
let ttfData = ttfReander.read(binaryData);
showTTFGlyf(ttfData);
},
onError() {
onSuccess(buffer) {
let woffBuffer = ttf2woff(buffer, ttf2woffoptions);
let base64str = woff2base64(woffBuffer);
setFont(base64str);
let saveBtn = $('.saveas');
saveBtn.attr('href', base64str);
saveBtn.attr('download', 'save.woff');
let ttfReader = new TTFReader();
let ttfData = ttfReader.read(buffer);
showTTFGlyf(ttfData);
},
onError() {
onSuccess(buffer) {
let svgBuffer = ttf2svg(buffer, {
metadata: 'fonteditor V0.1'
});
let base64str = svg2base64(svgBuffer);
setFont(base64str);
let saveBtn = $('.saveas');
saveBtn.attr('href', base64str);
saveBtn.attr('download', 'save.svg');
let ttfReader = new TTFReader();
let ttfData = ttfReader.read(buffer);
showTTFGlyf(ttfData);
},
onError() {
onSuccess(buffer) {
let ttfBuffer = eot2ttf(buffer);
let ttfReader = new TTFReader();
let ttfData = ttfReader.read(ttfBuffer);
let base64str = ttf2base64(ttfBuffer);
setFont(base64str);
showTTFGlyf(ttfData);
},
onError() {
reader.onload = function (e) {
let ttfReader = new TTFReader({
hinting: true
});
curttfData = ttfReader.read(e.target.result);
ttfmin();
};