How to use the fonteditor-core/ttf/ttfreader 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 kekee000 / fonteditor-core / demo / js / ttfparse.js View on Github external
onSuccess(binaryData) {
                let ttfReader = new TTFReader({
                    // hinting: true,
                    subset: [65, 0x160, 0x161, 0x162]
                });
                let ttfData = ttfReader.read(binaryData);
                console.log(ttfData);
            },
            onError() {
github kekee000 / fonteditor-core / test / spec / ttf / ttfreader.spec.js View on Github external
describe('读ttf hinting数据', function () {
    let fontObject = new TTFReader({
        hinting: true
    }).read(readData('baiduHealth-hinting.ttf'));

    it('test read hinting', function () {
        assert.equal(fontObject.cvt.length, 24);
        assert.equal(fontObject.fpgm.length, 371);
        assert.equal(fontObject.prep.length, 204);
        assert.equal(fontObject.gasp.length, 8);
        assert.equal(fontObject.GPOS.length, 18);
        fontObject.kern && assert.equal(fontObject.kern.length, 8);
    });

});
github kekee000 / fonteditor-core / test / spec / ttf / ttfwriter.spec.js View on Github external
describe('写ttf数据', function () {

    let fontObject = new TTFReader().read(readData('baiduHealth.ttf'));

    it('test write ttf', function () {
        let buffer = new TTFWriter().write(fontObject);
        assert.ok(buffer.byteLength > 1000);
        assert.ok(buffer.byteLength < 10000);

        let ttf = new TTFReader().read(buffer);

        assert.equal(ttf.version, 1);

        assert.equal(ttf.head.magickNumber, 1594834165);
        assert.equal(ttf.head.unitsPerEm, 512);

        assert.equal(ttf.post.format, 2);
        assert.equal(ttf.post.underlinePosition, 0);
        assert.equal(ttf.post.underlineThickness, 0);
github kekee000 / fonteditor-core / demo / js / woff2ttf.js View on Github external
onSuccess(buffer) {
            let ttfBuffer = woff2ttf(buffer, {
                inflate
            });

            let saveBtn = $('.saveas');
            saveBtn.attr('href', ttf2base64(ttfBuffer));
            saveBtn.attr('download', 'save.woff');

            let ttfReader = new TTFReader();
            let ttfData = ttfReader.read(ttfBuffer);
            console.log(ttfData);
        },
        onError() {
github kekee000 / fonteditor-core / demo / js / ttfwriter.js View on Github external
$.getJSON('./data/baiduHealth.json', function (ttf) {

            let reader = new TTFReader();
            let writer = new TTFWriter();
            let buffer = writer.write(ttf);

            let ttfData = reader.read(buffer);

            console.log(ttfData);

            let base64str = ttf2base64(buffer);
            let saveBtn = $('.saveas');
            saveBtn.attr('href', base64str);
            saveBtn.attr('download', 'save.ttf');
        });
    }
github kekee000 / fonteditor-core / demo / js / glyfcanvas.js View on Github external
onSuccess(binaryData) {
                setFont(binaryData);

                let ttfReander = new TTFReader();
                let ttfData = ttfReander.read(binaryData);
                showTTFGlyf(ttfData);
            },
            onError() {
github kekee000 / fonteditor-core / demo / js / ttf2woff.js View on Github external
onSuccess(buffer) {

            let woffBuffer = ttf2woff(buffer, ttf2woffoptions);

            let base64str = woff2base64(woffBuffer);
            setFont(base64str);


            let saveBtn = $('.saveas');
            saveBtn.attr('href', base64str);
            saveBtn.attr('download', 'save.woff');



            let ttfReader = new TTFReader();
            let ttfData = ttfReader.read(buffer);
            showTTFGlyf(ttfData);

        },
        onError() {
github kekee000 / fonteditor-core / demo / js / ttf2svg.js View on Github external
onSuccess(buffer) {

            let svgBuffer = ttf2svg(buffer, {
                metadata: 'fonteditor V0.1'
            });

            let base64str = svg2base64(svgBuffer);
            setFont(base64str);


            let saveBtn = $('.saveas');
            saveBtn.attr('href', base64str);
            saveBtn.attr('download', 'save.svg');

            let ttfReader = new TTFReader();
            let ttfData = ttfReader.read(buffer);
            showTTFGlyf(ttfData);

        },
        onError() {
github kekee000 / fonteditor-core / demo / js / ttf2eot.js View on Github external
onSuccess(buffer) {


            let ttfBuffer = eot2ttf(buffer);
            let ttfReader = new TTFReader();
            let ttfData = ttfReader.read(ttfBuffer);
            let base64str = ttf2base64(ttfBuffer);
            setFont(base64str);
            showTTFGlyf(ttfData);

        },
        onError() {
github kekee000 / fonteditor-core / demo / js / ttfmin.js View on Github external
reader.onload = function (e) {

        let ttfReader = new TTFReader({
            hinting: true
        });
        curttfData = ttfReader.read(e.target.result);

        ttfmin();
    };