foliojs / fontkit

An advanced font engine for Node and the browser
1.48k stars 219 forks source link

TypeError: Cannot read property 'tables' of undefined #136

Open quitequinn opened 7 years ago

quitequinn commented 7 years ago

I'm receiving a "TypeError: Cannot read property 'tables' of undefined" error when I run simple "example" functions with a woff. Below if what I'm running — do you now why this is happening?

var fontkit = require('fontkit');
var font = fontkit.openSync(pathToWoffFont);
var run = font.layout('hello world!');
var svg = run.glyphs[0].path.toSVG();
// this works
console.log(font);
// this errors — TypeError: Cannot read property 'tables' of undefined
console.log(svg);
quitequinn commented 7 years ago

Double checked — but same issue with TTF


TypeError: Cannot read property 'tables' of undefined
    at CmapProcessor.findSubtable (/Users/quitequinn/Desktop/GITS/The-Designers-Foundry/node_modules/fontkit/index.js:3895:38)
    at new CmapProcessor (/Users/quitequinn/Desktop/GITS/The-Designers-Foundry/node_modules/fontkit/index.js:3836:22)
    at TTFFont.get (/Users/quitequinn/Desktop/GITS/The-Designers-Foundry/node_modules/fontkit/index.js:14111:14)
    at TTFFont.descriptor.get (/Users/quitequinn/Desktop/GITS/The-Designers-Foundry/node_modules/fontkit/index.js:95:23)
    at TTFFont.glyphForCodePoint (/Users/quitequinn/Desktop/GITS/The-Designers-Foundry/node_modules/fontkit/index.js:13719:30)
    at TTFFont.glyphsForString (/Users/quitequinn/Desktop/GITS/The-Designers-Foundry/node_modules/fontkit/index.js:13766:26)
    at LayoutEngine.layout (/Users/quitequinn/Desktop/GITS/The-Designers-Foundry/node_modules/fontkit/index.js:10426:30)
    at TTFFont.layout (/Users/quitequinn/Desktop/GITS/The-Designers-Foundry/node_modules/fontkit/index.js:13787:31)
    at /Users/quitequinn/Desktop/GITS/The-Designers-Foundry/models/Typeface.js:642:27
    at /Users/quitequinn/Desktop/GITS/The-Designers-Foundry/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)
orklann commented 6 years ago
// open a font synchronously
var font = fontkit.openSync('Andale Mono.ttf');

// layout a string, using default shaping features.
// returns a GlyphRun, describing glyphs and positions.
var run = font.layout('A');

// get an SVG path for a glyph
var svg = run.glyphs[0].path.toSVG();
console.log(svg);

I tested the built-in macOS font Andale Mono.tff and it works. Maybe you can upload your font for testing, and maybe your font is invalid in format. Just guessing.