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.

Issue with custom font - Myriad-Pro-Bold

See original GitHub issue

I try to add custom font but it seem doesn’t work with all font

I can get Roboto.ttf work but it doesn’t work with this font - https://fontsgeek.com/fonts/Myriad-Pro-Bold

Got below error


sPDF PubSub Error Cannot use 'in' operator to search for '0' in undefined TypeError: Cannot use 'in' operator to search for '0' in undefined
    at GlyfTable.glyphFor (/Users/truongnguyen/Truong/pdf-generator/node_modules/jspdf/dist/jspdf.node.js:35270:12)
    at Subset.glyphsFor (/Users/truongnguyen/Truong/pdf-generator/node_modules/jspdf/dist/jspdf.node.js:35599:35)
    at Subset.encode (/Users/truongnguyen/Truong/pdf-generator/node_modules/jspdf/dist/jspdf.node.js:35638:19)
    at identityHFunction (/Users/truongnguyen/Truong/pdf-generator/node_modules/jspdf/dist/jspdf.node.js:30831:39)
    at Object.<anonymous> (/Users/truongnguyen/Truong/pdf-generator/node_modules/jspdf/dist/jspdf.node.js:30897:7)
    at PubSub.publish (/Users/truongnguyen/Truong/pdf-generator/node_modules/jspdf/dist/jspdf.node.js:404:18)
    at putFont (/Users/truongnguyen/Truong/pdf-generator/node_modules/jspdf/dist/jspdf.node.js:2273:12)
    at putFonts (/Users/truongnguyen/Truong/pdf-generator/node_modules/jspdf/dist/jspdf.node.js:2304:11)
    at putResources (/Users/truongnguyen/Truong/pdf-generator/node_modules/jspdf/dist/jspdf.node.js:2659:5)
    at API.__private__.buildDocument (/Users/truongnguyen/Truong/pdf-generator/node_modules/jspdf/dist/jspdf.node.js:3232:5)

Here is the code I added all the front


addFonts() {
    const fonts = fs.readdirSync('./fonts');
    for (const font of fonts) {
      const base64Front = fs.readFileSync('./fonts/' + font).toString('base64');

      this.doc.addFileToVFS(font, base64Front);
      const arr = font.split('.')[0].split('-');
      this.doc.addFont(font, arr[0], arr[1].toLocaleLowerCase());
    }
  }

Do we have the list or the requirements for the custom font support?

I already try fontconverter provided in other issue and compare base64 are same

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
samuraitruongcommented, Sep 23, 2020

@HackbrettXXX I think it is some problem with the variable of that fonts, I try with the same font name, but get the font from other source and it works for me now

If that something can be resolveable then it will good to fix, otherwise we need to learn which type of font supported and document it

This is the same font but work for me - https://github.com/celsodantas/wak/blob/master/app/assets/stylesheets/fonts/MyriadPro-Regular.ttf

0reactions
HackbrettXXXcommented, Oct 5, 2020

@listopadiya Thanks for the investigation. OTF fonts are not supported, but there is an open feature request: #2276. I added a comment about the CFF tables. I think we can close this now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with custom font - Myriad-Pro-Bold #2921 - GitHub
I try to add custom font but it seem doesn't work with all font I can get Roboto.ttf work ... Issue with custom...
Read more >
Bold and italic issue using Myriad pro font in the report - Telerik
Hello , I am using Myriad pro font in the report. There is no difference in the regular, bold and italic text of...
Read more >
css - Myriad pro font is not shown properly - Stack Overflow
I have tested on my local machine. the browser is chrome. <html> <head> <style type="text/css"> @font-face{ font-family: "Myriad-Pro"; ...
Read more >
Cannot compile Myriad Pro with FontPro - TeX
I found out that the problem was the capitalization in the names of the font files. Good: MyriadPro-Bold.otf. Bad: MyriadPro-BOLDIT.OTF.
Read more >
Cannot add custom fonts to templates - HubSpot Community
Any help would be appreciated, thank you! @font-face { font-family: 'Myriad Pro Bold Condensed'; src: url('https://20780731.fs1.
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