Skip to content

Commit 98cc66f

Browse files
committed
Fixed gasp support bugs per #738
1 parent 811a9c2 commit 98cc66f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/opentype.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,13 @@ function parseBuffer(buffer, opt={}) {
310310
metaTableEntry = tableEntry;
311311
break;
312312
case 'gasp':
313-
table = uncompressTable(data, tableEntry);
314-
font.tables.gasp = gasp.parse(table.data, table.offset);
313+
try {
314+
table = uncompressTable(data, tableEntry);
315+
font.tables.gasp = gasp.parse(table.data, table.offset);
316+
} catch (e) {
317+
console.warn('Failed to parse gasp table, skipping.');
318+
console.warn(e);
319+
}
315320
break;
316321
case 'SVG ':
317322
table = uncompressTable(data, tableEntry);

src/tables/gasp.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ function makeGaspTable(gasp) {
3434
{name: 'numRanges', type: 'USHORT', value: gasp.numRanges},
3535
]);
3636

37-
for (let i in gasp.numRanges) {
38-
result.fields.push({name: 'rangeMaxPPEM', type: 'USHORT', value: gasp.numRanges[i].rangeMaxPPEM});
39-
result.fields.push({name: 'rangeGaspBehavior', type: 'USHORT', value: gasp.numRanges[i].rangeGaspBehavior});
37+
for (let i in gasp.gaspRanges) {
38+
result.fields.push({name: 'rangeMaxPPEM', type: 'USHORT', value: gasp.gaspRanges[i].rangeMaxPPEM});
39+
result.fields.push({name: 'rangeGaspBehavior', type: 'USHORT', value: gasp.gaspRanges[i].rangeGaspBehavior});
4040
}
4141

4242
return result;

0 commit comments

Comments
 (0)