Pdfkit: Error when trying to embed woff2 font

Created on 11 Sep 2016  路  2Comments  路  Source: foliojs/pdfkit

In node, I've tried embedding a number of .woff2 fonts from Google Fonts but they all error with:

TypeError: Cannot read property 'length' of undefined                                                                                                                     
    at WOFF2Glyph._getContours (/node_modules/pdfkit/node_modules/fontkit/index.js:9464:33)                  
    at WOFF2Glyph._getPath (/node_modules/pdfkit/node_modules/fontkit/index.js:9499:27)                      
    at WOFF2Glyph.get (/node_modules/pdfkit/node_modules/fontkit/index.js:9067:19)                           
    at WOFF2Glyph.descriptor.get (/node_modules/pdfkit/node_modules/fontkit/index.js:92:21)                  
    at WOFF2Glyph._getCBox (/node_modules/pdfkit/node_modules/fontkit/index.js:11955:18)                     
    at WOFF2Glyph._getMetrics (/node_modules/pdfkit/node_modules/fontkit/index.js:9482:23)                   
    at WOFF2Glyph.get (/node_modules/pdfkit/node_modules/fontkit/index.js:9078:19)                           
    at WOFF2Glyph.descriptor.get (/node_modules/pdfkit/node_modules/fontkit/index.js:92:21)                  
    at new EmbeddedFont (/node_modules/pdfkit/js/font/embedded.js:23:43)                                     
    at Function.PDFFont.open (/node_modules/pdfkit/js/font.js:25:14) 

This simple project demonstrates the error.

Am I doing something wrong? All the .ttf files I've tried from Google Fonts appear to work fine.

bug fonts

Most helpful comment

This also occurs in the browser.

The WOFF 1 files I've tried also have another, different error. "Unknown op: 0". It seems to be in the "_getPath" function.

All 2 comments

This also occurs in the browser.

The WOFF 1 files I've tried also have another, different error. "Unknown op: 0". It seems to be in the "_getPath" function.

I had some luck in NodeJS by converting my TTF fonts to base64. More here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

huy-nguyen picture huy-nguyen  路  4Comments

stephen-last picture stephen-last  路  4Comments

durango picture durango  路  4Comments

vovkvlad picture vovkvlad  路  5Comments

edmelly picture edmelly  路  5Comments