Pomax / lib-font

This library adds a new Font() object to the JavaScript toolbox, similar to new Image() for images
MIT License
730 stars 72 forks source link

Testing character throws an error #57

Closed ghost closed 4 years ago

ghost commented 4 years ago

In the example there is this line of code:

     [`a`, `→`, `嬉`].forEach(char => console.log(`Font supports '${char}': ${
         font.supports(char)
     }`));

If it's not commented out, the font won't get loaded. Message:

Event {type: "error", detail: TypeError: this.get is not a function. (In 'this.get(tableID)', 'this.get' is undefined), msg: "Failed to load font at ./fonts/SourceCodeVariable-Roman.otf.woff2", __mayPropagate: true}

If I comment it out, there is no error. But why does it say that the font cant get loaded? How can I test which characters a font file has?

Pomax commented 4 years ago

I'd have to see more code than this, because it's missing the code that actually loads the font you're trying to use? Are you running the code from the README.md?

Pomax commented 4 years ago

I did a bit of digging based on that error, and it turns out it was a line of code that was using an old function name instead of the new one - I've updated the test cases to cover that code path, and fixed up the code. If you grab the latest master, things should now work.