How to use the fonteditor-core.TTF function in fonteditor-core

To help you get started, we’ve selected a few fonteditor-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecomfe / fontmin / plugins / glyph.js View on Github external
function minifyFontObject(ttfObject, subset, plugin) {

    // check null
    if (subset.length === 0) {
        return ttfObject;
    }

    // new TTF Object
    var ttf = new TTF(ttfObject);

    // get target glyfs then set
    ttf.setGlyf(getSubsetGlyfs(ttf, subset));

    // use plugin
    if (_.isFunction(plugin)) {
        plugin(ttf);
    }

    return ttf.get();
}
github ecomfe / fontmin / plugins / svgs2ttf.js View on Github external
fontSubFamily: name,
                uniqueSubFamily: name,
                postScriptName: name
            }
        },
        opts
    );

    // empty ttfobj
    var ttfobj = getEmptyttfObject();

    // for save name
    ttfobj.post.format = 2;

    // new TTF
    this.ttf = new TTF(ttfobj);

    // set name
    this.ttf.setName(this.opts.name);

    // unicode start
    this.startCode = opts.startCode || 0xe001;

}
github taggon / fonty / index.js View on Github external
inflate: null,
		combinePath: false,
	};

	const opts = normalizeOptions(options);
	if ( opts.subset ) {
		ttfOptions.subset = opts.subset;
	}

	const buffer = fs.readFileSync( input );
	const font = Font.create( buffer, ttfOptions );

	// alias empty space glyphs
	// If a font file doesn't include these empty glyphs, MS IE/Edge would display unknown .
	let space = null;
	const ttf = new TTF(font.get());

	if ( opts.subset ) {
		const spaceIndex = ttf.getGlyfIndexByCode(32);
		if ( spaceIndex !== -1 ) {
			space = ttf.getGlyfByIndex(spaceIndex);
			if ( space && space.unicode && space.unicode.indexOf(32) !== -1 ) {
				space.contours = [];

				[ 10, 13 ].forEach( code => {
					if ( space.unicode.indexOf(code) === -1 ) {
						space.unicode.push(code);
					}
				} );

				ttf.replaceGlyf(space, spaceIndex);
			} else {