question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Virtual file system Error: Helvetica.afm not found

See original GitHub issue

I’ve used this webpack example to extend my create-react-app setup. I’ve added the rules to my webpack.config.js but there must a problem with the asset inlining.

in fact this rule seems not to affect my generated webpack chunk: { loader: 'raw-loader', test: /\.afm$/ }

the following object is applied to the webpack output, which indicates that this a problem on the loader side and not a problem with the custom registerAFMFonts, which handles which fonts should be inlined:

var map = {
	"./Helvetica.afm": "./node_modules/pdfkit/js/data/Helvetica.afm"
};

But when i double check the chunk contents there are no inlined glyphs. That’s a pity because i really appreciated the approach with kicking out all the unnecessary embedded fonts for file size reasons. In fact everything up the stack trace works well until the PDFDocument constructor tries to load the standard Helvetica font file, then the app crashes with an uncaught error…

File 'data/Helvetica.afm' not found in virtual file system

The only thing i modified is the pattern which chooses the font variants. I only want the standard Helvetica to be inlined, like this:

registerAFMFonts(require.context('pdfkit/js/data', false, /Helvetica\.afm$/));

Here’s the trace:

Uncaught (in promise) Error: File 'data/Helvetica.afm' not found in virtual file system
    at VirtualFileSystem.readFileSync (virtual-fs.js:22)
    at Object.Helvetica (pdfkit.es5.js:2658)
    at new StandardFont (pdfkit.es5.js:2700)
    at Function.open (pdfkit.es5.js:3096)
    at PDFDocument.font (pdfkit.es5.js:3170)
    at PDFDocument.initFonts (pdfkit.es5.js:3132)
    at new PDFDocument (pdfkit.es5.js:4890)
    at new PDFBuilder (PDFBuilder.js:42)
    at PDFCreator.createID (index.jsx:40)
    at PDFCreator.componentDidMount (index.jsx:72)

Any ideas how to ensure that the file will be inlined into the chunk or safely referenced in the virtual file system? Tbh a solution to bypass the standard font loading would be also a good hint, because my tool explicitly loads a custom font. The Helvetica i’m trying to inline is just a workaround to keep things running without breaking the whole pdfkit font-setup logic.

Cheers and thx in advance

My environment

  • pdfkit version: 0.9.1
  • Node version: 11.12.0
  • Browser version : Chrome 74
  • Operating System: MacOS 10.14.5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
thetwcommented, Jun 4, 2019

This issue can be closed, it was an issue with accidentally calling the require context function on the Helvetica font after force importing the raw file.

0reactions
astururcommented, Jul 15, 2020

i tried various combinations, the webpack config and the browserified version. At the end i ended up taking the standalone version and copy pasting it in the project, and babel on top of it. With my current webpack config was the only thing that worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

File 'data/Helvetica.afm' not found in virtual file system · Issue #1
This issue can be closed, it was an issue with accidentally calling the require context function on the Helvetica font after force importing...
Read more >
PDFMAKE: 'Roboto-Regular.ttf' not found in virtual file system ...
I battled with this recently on stackblitz when using it with angular. the issue was pdfmake.vfs on the window object was not being...
Read more >
via Virtual file system (VFS) - pdfmake
1. create a new vfs_fonts.js containing your font files ... The above steps embeds all files from examples/fonts (into a local key/value variable...
Read more >
Export PDF with different Font not finding new font - DataTables
Error messages shown: Uncaught File 'CourierPrime-Regular.ttf' not found in virtual file system. Description of problem:.
Read more >
IJ41328: AFM: FILESET STUCK IN FLUSHONLY, RECOVERY ...
Error Description:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found