woff2-decode 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# woff2-decode
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A TypeScript WOFF2 decoder
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -23,7 +23,7 @@ The decoder handles both single fonts and TrueType Collections (TTC). For collec
|
|
|
23
23
|
|
|
24
24
|
## Performance
|
|
25
25
|
|
|
26
|
-
Benchmarks on an M1 Mac, Node 20. In Node, native Brotli (via zlib)
|
|
26
|
+
Benchmarks on an M1 Mac, Node 20. In Node, comparing native Brotli (via zlib)to pure JS used in browsers
|
|
27
27
|
|
|
28
28
|
| File | Size | Native | Pure JS |
|
|
29
29
|
|------|------|--------|---------|
|
|
@@ -31,23 +31,10 @@ Benchmarks on an M1 Mac, Node 20. In Node, native Brotli (via zlib) is used auto
|
|
|
31
31
|
| enc-ttf.woff2 | 98 KB | 4.0 ms | 7.1 ms |
|
|
32
32
|
| enc-var-ttf.woff2 | 318 KB | 6.8 ms | 15.1 ms |
|
|
33
33
|
|
|
34
|
-
CFF fonts decode faster because they skip the glyf/loca transform
|
|
35
|
-
|
|
36
|
-
## What Gets Decoded
|
|
37
|
-
|
|
38
|
-
WOFF2 is not just compressed font data. The spec defines transforms for certain tables:
|
|
39
|
-
|
|
40
|
-
- **glyf/loca**: Point coordinates are delta-encoded with a variable-length triplet scheme. Reconstructing these is the bulk of the decoder logic
|
|
41
|
-
- **hmtx**: Left side bearings can be stripped and reconstructed from glyph bounding boxes
|
|
42
|
-
|
|
43
|
-
Tables without transforms (including CFF, CFF2, and everything else) pass through after Brotli decompression
|
|
44
|
-
|
|
45
34
|
## API
|
|
46
35
|
|
|
47
36
|
```typescript
|
|
48
37
|
function decode(data: ArrayBuffer | Uint8Array): Uint8Array
|
|
49
38
|
```
|
|
50
39
|
|
|
51
|
-
Throws if the input is not valid WOFF2 or if decompression fails
|
|
52
|
-
|
|
53
40
|
MIT, maintained by [@jpt](https://github.com/jpt)
|