Skip to content

Commit

Permalink
Fixed gasp support bugs per opentypejs#738
Browse files Browse the repository at this point in the history
  • Loading branch information
Balearica authored and Connum committed Sep 9, 2024
1 parent f8108ec commit aea8c37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/opentype.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,13 @@ function parseBuffer(buffer, opt={}) {
metaTableEntry = tableEntry;
break;
case 'gasp':
table = uncompressTable(data, tableEntry);
font.tables.gasp = gasp.parse(table.data, table.offset);
try {
table = uncompressTable(data, tableEntry);
font.tables.gasp = gasp.parse(table.data, table.offset);
} catch (e) {
console.warn('Failed to parse gasp table, skipping.');
console.warn(e);
}
break;
case 'SVG ':
table = uncompressTable(data, tableEntry);
Expand Down
6 changes: 3 additions & 3 deletions src/tables/gasp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ function makeGaspTable(gasp) {
{name: 'numRanges', type: 'USHORT', value: gasp.numRanges},
]);

for (let i in gasp.numRanges) {
result.fields.push({name: 'rangeMaxPPEM', type: 'USHORT', value: gasp.numRanges[i].rangeMaxPPEM});
result.fields.push({name: 'rangeGaspBehavior', type: 'USHORT', value: gasp.numRanges[i].rangeGaspBehavior});
for (let i in gasp.gaspRanges) {
result.fields.push({name: 'rangeMaxPPEM', type: 'USHORT', value: gasp.gaspRanges[i].rangeMaxPPEM});
result.fields.push({name: 'rangeGaspBehavior', type: 'USHORT', value: gasp.gaspRanges[i].rangeGaspBehavior});
}

return result;
Expand Down

0 comments on commit aea8c37

Please sign in to comment.