foliojs/fontkit

fontkit wont load fonts in Node 23

Opened this issue · 2 comments

hello - I'm using Node 23 with next/font, and I've tracked down an issue with fonts not loading to this package.

var fontkit = require("fontkit");
var font = fontkit.openSync("Geist-Black.ttf");

Gives this error:

Error: Unknown font format

The error is "RangeError: Offset is outside the bounds of the DataView" and being thrown here:

var header = DFontHeader.decode(stream);

Which looks to be because Node 23 now throws an error when reading a buffer outside bounds:

nodejs/node#54588

I can reproduce with Node v23.4.0 on Arch Linux. How did you find the source of the error? It's all just minified garbage for me.

It seems to be fixed on 23.5.0 for some reason.