Skip to content

3.13.0

Choose a tag to compare

@matmen matmen released this 31 Oct 11:41
Immutable release. Only release title and notes can be modified.

This release brings WOFF fonts everywhere, smaller PNGs by default, much faster lossy WebP decoding and more accurate hinting. There are no breaking API changes, but PNGs come out smaller and a little slower by default (see below).

const inter = await fs.readFile('node_modules/@fontsource/inter/files/inter-latin-400-normal.woff');
await Image.renderText(inter, 32, 'Hello');   // WOFF fonts work in renderText, TextLayout and renderSVG
await image.encode();                         // PNG: compression level 4 by default (was 1)

WOFF fonts

renderText(), TextLayout and SVG rendering's fonts option take WOFF fonts now, not only TrueType and OpenType ones. Font packages like Fontsource ship only WOFF and WOFF2, so their fonts can be used directly. WOFF2 fonts are refused with a clear error for now: they need Brotli, which Chrome doesn't offer to JavaScript yet.

Smaller PNGs by default

PNG and APNG encoding default to compression level 4 instead of 1: files are 7-22% smaller (graphics 11%, photos 10%, screenshots 22%) for about 30% more encoding time. Pass compression: 1 for the previous speed. This applies in Node.js and Bun; elsewhere levels 1-6 already compressed like level 6.

Faster lossy WebP decoding

Lossy WebP decoding is about 45% faster (1920x1080 at quality 75: 184 → 100 ms), with the same pixels. The decoder's main loop kept getting deoptimized by V8: reading a DC prediction mode returned -0, which V8 treats as a floating point number.

More accurate hinting

TrueType hinting scales the fonts' control values exactly like FreeType. Before, some points could land 1/64 pixel off, sometimes across a pixel boundary: of one test font's glyphs at 11-128 px, 60 of 72 matched FreeType, now all of them do.

Tests

Many new tests cover the decoders' rarer paths, each against its reference implementation (libjpeg-turbo, libwebp, libvpx, libavif, libjxl, FreeType, HarfBuzz, resvg): unusual JPEG subsamplings and YCCK, interlaced GIFs and PNGs, every WebP loop filter variant, CID-keyed and flex CFF fonts, more complex script shaping, AV1 timing info, and the code paths for big endian machines.

See the changelog for the details.