How to use the fonteditor-core/ttf/ttf2woff 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 / fonteditor / src / fonteditor / widget / sync.js View on Github external
});
        }
        catch (e) {
            program.fire('font-error', e);
            alert(e.message);
            throw e;
        }

        if (syncConfig.ttf) {
            fontType.push('ttf');
            syncData.ttf = font.toBase64(buffer);
        }

        if (syncConfig.woff) {
            fontType.push('woff');
            syncData.woff = font.toBase64(ttf2woff(buffer));
        }

        if (syncConfig.eot) {
            fontType.push('eot');
            syncData.eot = font.toBase64(ttf2eot(buffer));
        }

        buffer = null;
    }

    if (syncConfig.svg) {
        fontType.push('svg');
        let svg = font.create(ttf).write({
            type: 'svg'
        });
        syncData.svg = font.toBase64(svg);
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);

        },