opentypejs / opentype.js

Read and write OpenType fonts using JavaScript.
https://opentype.js.org/
MIT License
4.37k stars 467 forks source link

Why did we depricate the load function? #675

Closed ILOVEPIE closed 1 month ago

ILOVEPIE commented 5 months ago

It's a perfectly good function that's useful.

vinuel commented 4 months ago

Came across this too lately and was wondering if there is any explanation or documentation about it...

Connum commented 4 months ago

The README was updated to state that the method is deprecated with this commit: https://github.com/opentypejs/opentype.js/commit/88c89dcdb2cc8952da9b270f39506afe2b715efa

The [deprecated] tag was added to the load() test cases in this commit: https://github.com/opentypejs/opentype.js/commit/a9acb24d90737c9432d77df38ede1c32e270c508 Maybe @yne can shed some light on it?

yne commented 4 months ago

Hi, the simple reason is that

Also, as demonstrated on the README, doing the path/fs to buffer only take 1 line anyway on the user-side (using require/import/fs/node:fs/fetch/XHR/net or whatever you need for your env/version/context)

the goal is to keep the lib out of those noises (look at the pain we have just to migrate to a module package.json)

I'd like to avoid that

Connum commented 4 months ago

@ILOVEPIE any thoughts in @yne's response?

axkibe commented 4 months ago

in my opinion opentype should concentrate itself on bein a typing library and avoid when reasonable doing the fluff around it. doing the fetch() is an example of this, since this also inclused error handling, improving startup speeds by adding preloads to html header, caching etc. let the user of the library do it*. The same applies on the other side, canvas stroking and filling, there is an argument for opentype making the path in canvas, otherwise we'd redo the same thing over and over translating the opentype.js datastructure into pathing commands.. but the fill and stroke? Leave it to the user, then they can decide on colors, translations etc. without bloating the library.

TLDR: it was a good/useful function, but there is an argument to be made it isn't in the focus of the lib. It's certainly a one-liner to fetch it yourself (without considering preloading, then its 2 lines).