You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EmbeddedFont#embed crashes when postscriptName is a Uint8Array (Hermes / React Native) #1687
In EmbeddedFont#embed (src/pdfkit, line ~32447 in the built bundle), the code assumes this.font.postscriptName is always a string:
const name = tag + '+' + this.font.postscriptName?.replaceAll(' ', '_');
However, fontkit's readString() returns a raw Uint8Array when TextDecoder doesn't support the requested encoding (e.g. x-mac-roman, utf-16be). This happens on Hermes (React Native), which only supports utf-8 and utf-16le.
This causes a TypeError: replaceAll is not a function at PDF generation time.
This handles all three cases (string, Uint8Array, null/undefined) and also replaces .replaceAll() with .replace(/ /g, '_') for broader engine compatibility.
Activity