Package Exports
- @decktape/fonteditor-core
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@decktape/fonteditor-core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
fonteditor-core
FontEditor core functions
Feature
- sfnt parse
- read, write, transform fonts (ttf, woff, eot, svg, otf)
- ttf glyph adjust
- svg to glyph
Usage
// read font file
var Font = require('fonteditor-core').Font;
var fs = require('fs');
var buffer = fs.readFileSync('font.ttf');
// read font data
var font = Font.create(buffer, {
type: 'ttf', // support ttf,woff,eot,otf,svg
subset: [65, 66], // only read `a`, `b` glyf
hinting: true, // save font hinting
compound2simple: true, // transform ttf compound glyf to simple
inflate: null, // inflate function for woff
combinePath: false, // for svg path
});
var fontObject = font.get();
console.log(Object.keys(fontObject));
/* => [ 'version',
'numTables',
'searchRenge',
'entrySelector',
'rengeShift',
'head',
'maxp',
'glyf',
'cmap',
'name',
'hhea',
'post',
'OS/2',
'fpgm',
'cvt',
'prep'
]
*/
// write font file
var buffer = font.write({
type: 'woff', // support ttf,woff,eot,otf,svg
hinting: true, // save font hinting
deflate: null, // deflate function for woff
});
// fs.writeFileSync('font.woff', buffer);
// to base64 str
font.toBase64({
type: 'ttf' // support ttf,woff,eot,svg
});
// optimize glyf
font.optimize()
// compound2simple
font.compound2simple()
// sort glyf
font.sort()
// find glyf
var result = font.find({
unicode: [65]
});
var result = font.find({
filter: function (glyf) {
return glyf.name == 'icon'
}
});
// merge another font object
font.merge(font1, {
scale: 1
});
Demo
edp webserver
open http://127.0.0.1:9999/demo
Related
License
MIT © Fonteditor