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
I used the property subset:true. If I set subset:false, the documents gets generated correctly, including the dashes character
What actually happened?
The program crashed with message:
/Users/timotheeg/work/signify/backend/node_modules/@pdf-lib/fontkit/dist/fontkit.umd.js:1531
if (offset + ext > buf.length) throw new RangeError('Index out of range');
^
RangeError: Index out of range
at checkInt (/Users/timotheeg/work/signify/backend/node_modules/@pdf-lib/fontkit/dist/fontkit.umd.js:1531:43)
at Uint8Array.writeUInt16BE (/Users/timotheeg/work/signify/backend/node_modules/@pdf-lib/fontkit/dist/fontkit.umd.js:1596:21)
at TTFSubset._addGlyph (/Users/timotheeg/work/signify/backend/node_modules/@pdf-lib/fontkit/dist/fontkit.umd.js:40914:17)
at TTFSubset.encode (/Users/timotheeg/work/signify/backend/node_modules/@pdf-lib/fontkit/dist/fontkit.umd.js:40952:13)
at /Users/timotheeg/work/signify/backend/node_modules/@pdf-lib/fontkit/dist/fontkit.umd.js:40692:14
at Item.run (/Users/timotheeg/work/signify/backend/node_modules/@pdf-lib/fontkit/dist/fontkit.umd.js:2632:13)
at Timeout.drainQueue [as _onTimeout] (/Users/timotheeg/work/signify/backend/node_modules/@pdf-lib/fontkit/dist/fontkit.umd.js:2597:35)
at listOnTimeout (node:internal/timers:564:17)
at process.processTimers (node:internal/timers:507:7)
What did you expect to happen?
Document generation should succeed and export just the glyphs being used.
How can we reproduce the issue?
const{ PDFDocument, rgb }=require('pdf-lib');constfontkit=require('@pdf-lib/fontkit');constfs=require('fs/promises');(async()=>{constpoppinsRegularFontBytesWeb=await(awaitfetch('https://fonts.gstatic.com/s/poppins/v20/pxiEyp8kv8JHgFVrJJfecnFHGPc.woff2')).arrayBuffer()constdocContent=awaitfs.readFile('./Some_Dummy_PDF.pdf')constpdfDoc=awaitPDFDocument.load(docContent)pdfDoc.registerFontkit(fontkit)constfontPoppinsRegular=awaitpdfDoc.embedFont(poppinsRegularFontBytesWeb,{customName: 'PoppinsRegular',subset: true// set to false to see output with dash})constpages=pdfDoc.getPages()constpage=pages[0]consttextOffsetX=page.getWidth()*0.1consttextOffsetY=page.getHeight()*0.5page.drawText('Text with Dash -',{// remove dash and it works, colon, coma, work either wayx: textOffsetX,y: textOffsetY,size: 10,color: rgb(0,0,0),font: fontPoppinsRegular,})constpdfBytes=awaitpdfDoc.save()awaitfs.writeFile('./out.pdf',pdfBytes);})();
What were you trying to do?
Embed just a subset of a font into a pdf.
How did you attempt to do it?
I used the property subset:true. If I set
subset:false
, the documents gets generated correctly, including the dashes characterWhat actually happened?
The program crashed with message:
What did you expect to happen?
Document generation should succeed and export just the glyphs being used.
How can we reproduce the issue?
Some_Dummy_PDF.pdf
out.pdf
Version
1.17.1
What environment are you running pdf-lib in?
Node
Checklist
Additional Notes
No response
The text was updated successfully, but these errors were encountered: