It was throw exception TypeError:Undefined is not an object (evaluationg 'cff.topDict') when i loaded Apple PingFang Font and called fontData.glyphForCodePoint(120)
code:
fontData = fontkit.create(toBuffer(fontBase64Str));
xheight = getFontXHeight(fontData);
function toBuffer(base64data) {
var buffer = new Buffer(base64data,'base64');
return buffer
}
function getFontXHeight(fontData) {
fontData = fontData.glyphForCodePoint(120);
if (0 != fontData.id) {
return fontData = fontData.bbox;
} else {
return fontData.maxY - fontData.minY;
}
}
it was word well when loaded other font