An addon to support woff2 fonts in p5.js 2.0
Add a script tag to your sketch:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.woff2.js"></script>On OpenProcessing, add a custom library with this URL:
https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.woff2.js
I've included the WASM Brotli decompressor from wawoff2 on NPM, with some slight modifications to get it to import easily in the browser.
With it, I patch the p5.Font implementation in p5.js 2.0 to decompress font files with this decompressor if a woff2 font is loaded.
Install dependencies with npm install.
Running npm run build will run rollup from the src/ directory and create the final bundle in the lib/ directory.