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.

Can't use custom fonts properly

See original GitHub issue

I am using the 1.4.1 version of jsPDF in my Angular 5 project. I’m trying to add some custom fonts to my pdf but it’s not working. It throws the following error :

Font does not exist in FileInVFS, import fonts or remove declaration doc.addFont('nameOfTheFont').

So i tried to add files to VFS like this :

doc = new jsPDF();
doc.addFileToVFS(nameOfTheFont, FontBase64Encoded);

And it’s not throwing errors anymore, the PDF is well generated but the font is not working at all in the pdf.

capture

Did I missed something ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
adrien-guyotcommented, Jul 3, 2018

I tried to add “WinAnsiEncoding” at the end and it gets better (just a little because instead of unreadable characters, i have default font characters now).

doc.addFont(nameOfTheFont, nameOfTheFont,"normal","WinAnsiEncoding");

Even if it is still throwing the same error message, I do see the name of the font when i do a console.log(doc.getFontList()); but it’s not displaying the proper font when i set it.

0reactions
Uzlopakcommented, Sep 6, 2018

I think it is duplicate of #1902

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Installed Fonts That Won't Work - Lifewire
Easiest fix: Download and reinstall the correct version of the file, making sure the font is compatible with your operating system.
Read more >
Common Mistakes With Adding Custom Fonts to Your iOS App
It's pretty easy to add your own fonts in your iOS app but there are some common pitfalls to watch out for. Let...
Read more >
How To Load and Use Custom Fonts with CSS | DigitalOcean
You can use the @font-face rule to load a custom font on a web page. The history of loading custom fonts has lead...
Read more >
Custom Fonts Not Displaying On Front End - Elementor
Go to Elementor > Custom Fonts. If the URLs listed do not begin with https, click the DELETE button next to each, and...
Read more >
custom font not showing properly using @font-face
After much review, I can't get the correct display of a custom font I created through fontsquirrel. Chrome's Inspector shows the icon is...
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