How to use the fonteditor-core.TTFWriter 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 / otf2ttf.js View on Github external
this.push(file.clone(false));
        }

        // replace ext
        file.path = replaceExt(file.path, '.ttf');

        // ttf info
        var ttfBuffer;
        var ttfObj;

        // try otf2ttf
        try {

            ttfObj = otf2ttfobject(b2ab(file.contents), opts);

            ttfBuffer = ab2b(new TTFWriter(opts).write(ttfObj));

        }
        catch (ex) {
            cb(ex);
        }

        if (ttfBuffer) {
            file.contents = ttfBuffer;
            file.ttfObject = ttfObj;
            cb(null, file);
        }

    });
github ecomfe / fontmin / plugins / svg2ttf.js View on Github external
}

        // replace ext
        file.path = replaceExt(file.path, '.ttf');


        // ttf buffer
        var output;

        try {

            var ttfObj = svg2ttfobject(
                file.contents.toString('utf-8')
            );

            output = ab2b(new TTFWriter(opts).write(ttfObj));

        }
        catch (ex) {
            cb(ex);
        }

        if (output) {
            file.contents = output;
            cb(null, file);
        }

    });
github ecomfe / fontmin / plugins / svgs2ttf.js View on Github external
SvgFont.prototype.compile = function () {

    if (this.opts.adjust) {
        this.ttf.adjustGlyfPos(null, this.opts.adjust);
        this.ttf.adjustGlyf(null, this.opts.adjust);
    }

    this.contents = ab2b(
        new TTFWriter(
            this.opts
        )
        .write(
            this.ttf.ttf
        )
    );

};
github ecomfe / fontmin / plugins / glyph.js View on Github external
opts = opts || {};

    var ttfobj = contents;

    if (Buffer.isBuffer(contents)) {
        ttfobj = new TTFReader(opts).read(b2ab(contents));
    }

    var miniObj = minifyFontObject(
        ttfobj,
        opts.subset,
        opts.use
    );

    var ttfBuffer = ab2b(
        new TTFWriter(opts).write(miniObj)
    );

    return {
        object: miniObj,
        buffer: ttfBuffer
    };

}