Closed darknoon closed 2 years ago
Aye, that's by design (because loading things immediately can cause memory to blow up, so a lot of stuff is deferred). You can use font.opentype.directory
to get all known tables:
const { directory, tables } = font.opentype;
const knownTables = directory.map(e => e.tag.trim())
knownTables.forEach( name => {
console.log(tables[name]); // still fairly shallow
});
Wouldn't making the properties enumerable not impose any performance delta, though?
ie Object.keys()
is still cheap until you actually access the data in the table.
we could add enumerable as property option, and see what it does if you want to give that a shot,
landed in 2.4.0
I tried doing
Object.keys(font.opentype.tables)
to get the tables that the font contains but it just returns[]
I think this is due to lazy.js
where
Object.defineProperty(…)
has via MDN:I couldn't find much documentation, so it wasn't clear if this is somehow intended. Is there a better way to accomplish this?