Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}).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');
});
}
function setFont(arrayBuffer) {
let base64 = ttf2base64(arrayBuffer);
setFontface('truetype', base64, 'font-face');
}
function setFont(arrayBuffer) {
let base64 = ttf2base64(arrayBuffer);
setFontface('truetype', base64, 'font-face');
}
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);
}
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());
setFont({
family: family,
data: ttf2base64(buffer)
}, '#' + family);
$('.ttf-text').html(text);