How to use the fonteditor-core/ttf/font.create 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 / loader.js View on Github external
function readttf(buffer, options) {
    // 暂不支持otf直接编辑,这里需要将otf转换成ttf
    if (options.type === 'woff') {
        options.inflate = inflate.inflate;
    }
    let ttf =  font.create(buffer, options).data;
    delete options.inflate;

    return ttf;
}
github ecomfe / fonteditor / src / fonteditor / widget / sync.js View on Github external
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);
    }

    syncData.encode = 'base64';
    syncData.fontName = syncConfig.name;
    syncData.fontType = fontType.join(',');
    return syncData;
}
github ecomfe / fonteditor / src / fonteditor / widget / loader.js View on Github external
function svg2ttf(buffer) {
    let options = program.setting.get('ie').import;
    options.type = 'svg';
    return font.create(buffer, options).data;
}
github ecomfe / fonteditor / src / fonteditor / widget / sync.js View on Github external
function getSyncData(syncConfig, ttf) {
    let fontType = [];
    let syncData = {};
    let buffer = null;
    if (syncConfig.woff || syncConfig.ttf || syncConfig.eot) {
        ttf = resolvettf(ttf);
        try {
            buffer = font.create(ttf).write({
                type: 'ttf'
            });
        }
        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');