Skip to content

Commit 505907d

Browse files
committed
Read checksum in parseWOFFTableEntries.
1 parent eab791a commit 505907d

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

src/opentype.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function parseWOFFTableEntries(data, numTables) {
8080
const offset = parse.getULong(data, p + 4);
8181
const compLength = parse.getULong(data, p + 8);
8282
const origLength = parse.getULong(data, p + 12);
83+
const checksum = parse.getULong(data, p + 16);
8384
let compression;
8485
if (compLength < origLength) {
8586
compression = 'WOFF';
@@ -88,7 +89,7 @@ function parseWOFFTableEntries(data, numTables) {
8889
}
8990

9091
tableEntries.push({tag: tag, offset: offset, compression: compression,
91-
compressedLength: compLength, length: origLength});
92+
compressedLength: compLength, length: origLength, checksum: checksum});
9293
p += 20;
9394
}
9495

src/woff-to-otf.mjs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ function woff_to_otf(buffer) {
2525
if (signature !== 'wOFF')
2626
throw new Error(`TYPE ERROR signature must be wOFF but is: "${signature}"`);
2727

28-
// need flavour??? -> opentype header syff!
2928
const flavor = parse.getTag(data, 4)
3029
, numTables = parse.getUShort(data, 12)
3130
, tableEntries = parseWOFFTableEntries(data, numTables)
@@ -48,28 +47,7 @@ function woff_to_otf(buffer) {
4847
, ...encode.USHORT(entrySelector)
4948
, ...encode.USHORT(rangeShift)
5049
);
51-
let offset = out.length;
52-
for (let i=0; i<numTables; i++) {
53-
// This is done in parseWOFFTableEntries already, minus the checksum:
54-
// tableEntries.push({tag: tag, offset: offset, compression: compression,
55-
// compressedLength: compLength, length: origLength});
56-
// Hence, we just amend the checksum.
57-
// Maybe, checksum could be added in parseWOFFTableEntries
58-
59-
// let p = 44; // offset to the first table directory entry.
60-
const pointerBase = 44 + i * 20;
61-
// tableDirectoryEntries.push({
62-
// tag: parse.getTag(data, pointerBase)
63-
// , offset: parse.getULong(data, pointerBase + 4)
64-
// , compLength: parse.getULong(data, pointerBase + 8)
65-
// , origLength: parse.getULong(data, pointerBase + 12)
66-
// , origChecksum: parse.getULong(data, pointerBase + 16)
67-
// });
68-
// p += 20;
69-
tableEntries[i].checksum = parse.getULong(data, pointerBase + 16);
70-
offset += 4 * 4;
71-
}
72-
// offset += numTables * 16;
50+
let offset = out.length + numTables * 16;
7351

7452
for (let i=0; i<numTables; i++) {
7553
const tableEntry = tableEntries[i];

0 commit comments

Comments
 (0)