Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
assert.equal(ttf.hhea.advanceWidthMax, 682);
assert.equal(ttf.hhea.ascent, 480);
}).done(function (data) {
let ttfObject = svg2ttfobject(data);
let writer = new TTFWriter();
let ttfBuffer = writer.write(ttfObject);
let base64str = ttf2base64(ttfBuffer);
let saveBtn = $('.saveas');
saveBtn.attr('href', base64str);
saveBtn.attr('download', 'save.ttf');
console.log(ttfObject);
});
$.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');
});
}
return u.charCodeAt(0);
})
});
if (indexList.length) {
let glyfList = ttf.getGlyf(indexList);
glyfList.unshift(ttf.getGlyfByIndex(0));
ttf.get().glyf = glyfList;
}
else {
ttf.get().glyf = [ttf.getGlyfByIndex(0)];
}
let family = 'font-with-hitting';
ttf.get().name.fontFamily = family;
let writer = new TTFWriter({
hinting: true
});
let buffer = writer.write(ttf.get());
setFont({
family: family,
data: ttf2base64(buffer)
}, '#' + family);
family = 'font-without-hitting';
ttf.get().name.fontFamily = family;
writer = new TTFWriter({
hinting: false
});
buffer = writer.write(ttf.get());
let family = 'font-with-hitting';
ttf.get().name.fontFamily = family;
let writer = new TTFWriter({
hinting: true
});
let buffer = writer.write(ttf.get());
setFont({
family: family,
data: ttf2base64(buffer)
}, '#' + family);
family = 'font-without-hitting';
ttf.get().name.fontFamily = family;
writer = new TTFWriter({
hinting: false
});
buffer = writer.write(ttf.get());
setFont({
family: family,
data: ttf2base64(buffer)
}, '#' + family);
$('.ttf-text').html(text);
}