How to use the fonteditor-core/common/lang.clone 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 / otfreader.js View on Github external
function showGlyf(charcode) {

    let glyf = lang.clone(ttf.getGlyfByCode(charcode));

    let canvas = $('#glyf-canvas').get(0);
    let ctx = canvas.getContext('2d');

    // 调整大小
    ctx.clearRect(0, 0, 600, 600);

    otfGlyf2Canvas(glyf, ctx, {
        stroke: 0,
        scale: 600 / ttf.ttf.head.unitsPerEm,
        height: ttf.ttf.head.unitsPerEm + ttf.ttf.hhea.descent,
        strokeStyle: 'green',
        fillStyle: 'green'
    });
}
github kekee000 / fonteditor-core / demo / js / glyfsvg.js View on Github external
function showGlyf(charcode) {

    let tpl = ''
        + '<svg class="glyf">'
        + ' <g>'
        +   '<path d="M 0,0" class="path"></path>'
        +   '</g>'
        +  '</svg>';
    let svg = $(tpl);
    let glyf = lang.clone(ttf.getGlyfByCode(charcode));

    if (glyf.compound) {
        return;
    }

    // 调整大小
    let width =  glyf.xMax;
    let height =  glyf.yMax - glyf.yMin;
    let scale = 1;

    if (ttf.ttf.head.unitsPerEm &gt; 512) {
        scale = 512 / ttf.ttf.head.unitsPerEm;
        width = width * scale;
        height = height * scale;
    }
github kekee000 / fonteditor-core / demo / js / glyfcanvas.js View on Github external
function showGlyf(charcode) {

    let glyf = lang.clone(ttf.getGlyfByCode(charcode));
    if (glyf.compound) {
        glyf.glyfs.forEach(g => {
            g.glyf = ttf.getGlyfByIndex(g.glyphIndex);
        });
    }

    let canvas = $('#glyf-canvas').get(0);
    let ctx = canvas.getContext('2d');

    // 调整大小
    let width =  glyf.xMax - glyf.xMin;
    let height =  glyf.yMax - glyf.yMin;
    let scale = 1;
    if (ttf.ttf.head.unitsPerEm > 512) {
        scale = 512 / ttf.ttf.head.unitsPerEm;
        width = width * scale;
github kekee000 / fonteditor-core / demo / js / ttfmin.js View on Github external
function ttfmin() {

    if (!curttfData) {
        return;
    }

    let text = $('#text').val();
    let ttf = new TTF(lang.clone(curttfData));

    let indexList = ttf.findGlyf({
        unicode: text.split('').map(function (u) {
            return u.charCodeAt(0);
        })
    });

    if (indexList.length) {
        let glyfList = ttf.getGlyf(indexList);
        glyfList.unshift(ttf.getGlyfByIndex(0));
        ttf.get().glyf = glyfList;
    }
    else {
        ttf.get().glyf = [ttf.getGlyfByIndex(0)];
    }