When using certain fonts (pdfkit.font(...)) and writing text with them (pdfDoc.text(...)), the script crashes with "Cannot access 'pts' before initialization".
This bug was actually fixed in foliojs/fontkit, here: foliojs/fontkit#286.
But, this fix is not yet released or tagged in foliojs/fontkit.
The request is to bring the fix in foliojs/pdfkit.