foliojs / fontkit

An advanced font engine for Node and the browser
1.45k stars 213 forks source link

Consider bringing back improvements from @pdf-lib/fontkit #277

Closed lehni closed 2 years ago

lehni commented 2 years ago

We are currently using the fontkit version from @pdf-lib/fontkit for some features on https://lineto.com/, mainly for the technical section. It would be great to be able to use the official version for the frontend too. Perhaps those adjustments in @pdf-lib/fontkit can be merged here?

PS: A good example for the use of fontkit is https://lineto.com/typefaces/blankenhorn/technical, where thousands of unencoded glyphs are displayed as SVGs, directly extracted from the webfont using fontkit.

lehni commented 2 years ago

The only problem with doing so right now is the dependency on 'fs' for loading some internal data. @pdf-lib/fontkit replaces those with required JSON files, I guess the ESM way would be to have them in JS files, but this doesn't sound like too far off?

devongovett commented 2 years ago

What features/bug fixes from that fork are you using? I don't have a whole lot of time, but if someone wants to send some PRs that might be helpful.

lehni commented 2 years ago

I'm not sure which ones I need, it just works for us while the official version doesn't.

There's a detailed list of the changes:

https://github.com/Hopding/fontkit#readme

I believe these are the important ones:

https://github.com/Hopding/fontkit/commit/968e35c158589294e9543818f56d0b229b95a475 https://github.com/Hopding/fontkit/commit/f674bf2e3c8a8e0a34083e19f0abe65df20520e3 https://github.com/Hopding/fontkit/commit/9363d1f8e97985d8a94ee6dac1fac39631ee3c77

devongovett commented 2 years ago

first and last one should already be handled in the latest version

ptoussai commented 2 years ago

With your changes it "almost" works out of the box in the browser. Thank you for that. With Webpack I had to set node.fs: 'empty' to make it stop complain about the missing fs module.

This is fixed with https://github.com/foliojs/fontkit/pull/280. This is also needed: https://github.com/foliojs/brotli.js/pull/22

That's it!

devongovett commented 2 years ago

I think all of this should be solved in v2.0.0

ptoussai commented 2 years ago

Thanks! However updating to brotli:1.3.3 is still needed.