opentypejs / opentype.js

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

Save/export font as WOFF (in Node.js) #507

Closed yvele closed 2 years ago

yvele commented 2 years ago

I searched everywhere but I didn't found in the documentation how to export a font to WOFF in Node.js. I'm able to use font.toArrayBuffer() to get the OTF.

Is there a way to directly get a WOFF binary?

Back in 2015 some people where talking about that feature:

Maybe a workaround to convert OTF to WOFF using an other library?

I found a ttf2woff library.. but no way to get an otf2woff equivalent 🤔 (even though some websites allows converting OTF to WOFF online).

Maybe related to:

yne commented 2 years ago

Hi,

woff2_compress works fine for me.

sudo apt install woff2
woff2_compress my.otf # will create my.woff2

Don't expect WOFF/2 output as it would require additional compression algorithms (zlib for WOFF and brotli for WOFF2)

It's better to write programs that do one thing and do it well ;)