diff --git a/README.md b/README.md index 5887873d..7d53fd01 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ If you plan on improving or debugging opentype.js, you can: ## Usage -### Loading a font +### Loading a WOFF/OTF/TTF font ```js // case 1: from an URL @@ -81,17 +81,41 @@ const buffer = require('fs').promises.readFile('./my.woff'); const buffer = document.getElementById('myfile').files[0].arrayBuffer(); // if running in async context: -const font = opentype.parse(await data); -console.log(font.supported); +const font = opentype.parse(await buffer); +console.log(font); // if not running in async context: buffer.then(data => { const font = opentype.parse(data); - // ... play with `font` ... - console.log(font.supported); + console.log(font); }) ``` +### Loading a WOFF2 font + +WOFF2 Brotli compression perform [29% better](https://www.w3.org/TR/WOFF20ER/#appendixB) than it WOFF predecessor. +But this compression is also more complex, and would result having a much heavier opentype.js library (~120KB => ~1400KB). + +To solve this: Decompress the font beforehand (for example with [fontello/wawoff2](https://github.com/fontello/wawoff2)). + +```js +// promise-based utility to load libraries using the good old - - -
-