Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var len, woffDataChains = [];
for (i = 0; i < entries.length; ++i) {
tableEntry = entries[i];
var sfntData = new ByteBuffer(buf.buffer, tableEntry.Offset, tableEntry.Length);
if (tableEntry.Tag.toString() === 'head') {
version.maj = sfntData.getUint16(SFNT_ENTRY_OFFSET.VERSION_MAJ);
version.min = sfntData.getUint16(SFNT_ENTRY_OFFSET.VERSION_MIN);
flavor = sfntData.getUint32(SFNT_ENTRY_OFFSET.FLAVOR);
sfntData.setUint32 (SFNT_ENTRY_OFFSET.CHECKSUM_ADJUSTMENT, checksumAdjustment);
}
var res = deflate(sfntData.toArray());
var compLength;
// We should use compression only if it really save space (standard requirement).
// Also, data should be aligned to long (with zeros?).
compLength = Math.min(res.length, sfntData.length);
len = longAlign(compLength);
var woffData = new ByteBuffer(len);
woffData.fill(0);
if (res.length >= sfntData.length) {
woffData.writeBytes(sfntData.toArray());
} else {
woffData.writeBytes(res);
function woffAppendMetadata(src, metadata) {
var zdata = deflate(metadata);
src.setUint32(WOFF_OFFSET.SIZE, src.length + zdata.length);
src.setUint32(WOFF_OFFSET.META_OFFSET, src.length);
src.setUint32(WOFF_OFFSET.META_LENGTH, zdata.length);
src.setUint32(WOFF_OFFSET.META_ORIG_LENGTH, metadata.length);
//concatenate src and zdata
var buf = new ByteBuffer(src.length + zdata.length);
buf.writeBytes(src.toArray());
buf.writeBytes(zdata);
return buf;
}