How to use fontmin - 10 common examples

To help you get started, we’ve selected a few fontmin 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 edmondyip / ChineseFonts / index.js View on Github external
};

// word count
function wordCount(str) {
  var text = removeDupicateText(str)
  var matches = text.match(/[\u00ff-\uffff]|\S+/g);
  return matches ? matches.length : 0;
}

// print all text
console.log('Converted words : ' + removeDupicateText(allText),'(' + wordCount(allText) + ')');

// convert file type
var fontmin = new Fontmin()
  .src(fontsSource)
  .use(Fontmin.glyph({
    text: allText
  }))
  .use(ttf2woff2({
    clone: true
  })) // add woff2
  .dest(outputPath)
  .use(Fontmin.ttf2eot())
  .use(Fontmin.ttf2woff({
    deflate: true
  }))
  .use(Fontmin.ttf2svg());
imagemin([outputPath + '*.svg'], outputPath + 'optimize', {
  use: [svgo()]
}).then(() => {
  console.log('Convert finished'); // Finished
});
github edmondyip / ChineseFonts / index.js View on Github external
// print all text
console.log('Converted words : ' + removeDupicateText(allText),'(' + wordCount(allText) + ')');

// convert file type
var fontmin = new Fontmin()
  .src(fontsSource)
  .use(Fontmin.glyph({
    text: allText
  }))
  .use(ttf2woff2({
    clone: true
  })) // add woff2
  .dest(outputPath)
  .use(Fontmin.ttf2eot())
  .use(Fontmin.ttf2woff({
    deflate: true
  }))
  .use(Fontmin.ttf2svg());
imagemin([outputPath + '*.svg'], outputPath + 'optimize', {
  use: [svgo()]
}).then(() => {
  console.log('Convert finished'); // Finished
});
fontmin.run(function(err, files) {
  if (err) {
    throw err;
  }
});
github junmer / icon-font / source.js View on Github external
catch (err) {
        return false;
    }
};

if (src.length > 1 && !isFile(src[src.length - 1])) {
    dest = src[src.length - 1];
    src.pop();
}

// start fontmin
new Fontmin()
    .src(src)
    .use(Fontmin.svgs2ttf(fmOpts.fontFamily, fmOpts))
    .use(Fontmin.ttf2eot(fmOpts))
    .use(Fontmin.ttf2woff(fmOpts))
    .use(Fontmin.ttf2svg(fmOpts))
    .use(Fontmin.css(fmOpts))
    .use(dump(fmOpts))
    .dest(dest || 'output')
    .run((err, files, stream) => {

        if (err) {
            log(err);
            process.exit(1);
        }

        files.forEach(file => {
            log(`created: ${file.path}`);
        });

        log(`\nall ${files.length} files`);
github edmondyip / ChineseFonts / index.js View on Github external
}

// print all text
console.log('Converted words : ' + removeDupicateText(allText),'(' + wordCount(allText) + ')');

// convert file type
var fontmin = new Fontmin()
  .src(fontsSource)
  .use(Fontmin.glyph({
    text: allText
  }))
  .use(ttf2woff2({
    clone: true
  })) // add woff2
  .dest(outputPath)
  .use(Fontmin.ttf2eot())
  .use(Fontmin.ttf2woff({
    deflate: true
  }))
  .use(Fontmin.ttf2svg());
imagemin([outputPath + '*.svg'], outputPath + 'optimize', {
  use: [svgo()]
}).then(() => {
  console.log('Convert finished'); // Finished
});
fontmin.run(function(err, files) {
  if (err) {
    throw err;
  }
});
github junmer / icon-font / source.js View on Github external
}
    catch (err) {
        return false;
    }
};

if (src.length > 1 && !isFile(src[src.length - 1])) {
    dest = src[src.length - 1];
    src.pop();
}

// start fontmin
new Fontmin()
    .src(src)
    .use(Fontmin.svgs2ttf(fmOpts.fontFamily, fmOpts))
    .use(Fontmin.ttf2eot(fmOpts))
    .use(Fontmin.ttf2woff(fmOpts))
    .use(Fontmin.ttf2svg(fmOpts))
    .use(Fontmin.css(fmOpts))
    .use(dump(fmOpts))
    .dest(dest || 'output')
    .run((err, files, stream) => {

        if (err) {
            log(err);
            process.exit(1);
        }

        files.forEach(file => {
            log(`created: ${file.path}`);
        });
github junmer / icon-font / source.js View on Github external
return false;
    }
};

if (src.length > 1 && !isFile(src[src.length - 1])) {
    dest = src[src.length - 1];
    src.pop();
}

// start fontmin
new Fontmin()
    .src(src)
    .use(Fontmin.svgs2ttf(fmOpts.fontFamily, fmOpts))
    .use(Fontmin.ttf2eot(fmOpts))
    .use(Fontmin.ttf2woff(fmOpts))
    .use(Fontmin.ttf2svg(fmOpts))
    .use(Fontmin.css(fmOpts))
    .use(dump(fmOpts))
    .dest(dest || 'output')
    .run((err, files, stream) => {

        if (err) {
            log(err);
            process.exit(1);
        }

        files.forEach(file => {
            log(`created: ${file.path}`);
        });

        log(`\nall ${files.length} files`);
github edmondyip / ChineseFonts / index.js View on Github external
// convert file type
var fontmin = new Fontmin()
  .src(fontsSource)
  .use(Fontmin.glyph({
    text: allText
  }))
  .use(ttf2woff2({
    clone: true
  })) // add woff2
  .dest(outputPath)
  .use(Fontmin.ttf2eot())
  .use(Fontmin.ttf2woff({
    deflate: true
  }))
  .use(Fontmin.ttf2svg());
imagemin([outputPath + '*.svg'], outputPath + 'optimize', {
  use: [svgo()]
}).then(() => {
  console.log('Convert finished'); // Finished
});
fontmin.run(function(err, files) {
  if (err) {
    throw err;
  }
});
github junmer / icon-font / source.js View on Github external
}
};

if (src.length > 1 && !isFile(src[src.length - 1])) {
    dest = src[src.length - 1];
    src.pop();
}

// start fontmin
new Fontmin()
    .src(src)
    .use(Fontmin.svgs2ttf(fmOpts.fontFamily, fmOpts))
    .use(Fontmin.ttf2eot(fmOpts))
    .use(Fontmin.ttf2woff(fmOpts))
    .use(Fontmin.ttf2svg(fmOpts))
    .use(Fontmin.css(fmOpts))
    .use(dump(fmOpts))
    .dest(dest || 'output')
    .run((err, files, stream) => {

        if (err) {
            log(err);
            process.exit(1);
        }

        files.forEach(file => {
            log(`created: ${file.path}`);
        });

        log(`\nall ${files.length} files`);

    });
github junmer / icon-font / source.js View on Github external
try {
        return fs.statSync(path).isFile();
    }
    catch (err) {
        return false;
    }
};

if (src.length > 1 && !isFile(src[src.length - 1])) {
    dest = src[src.length - 1];
    src.pop();
}

// start fontmin
new Fontmin()
    .src(src)
    .use(Fontmin.svgs2ttf(fmOpts.fontFamily, fmOpts))
    .use(Fontmin.ttf2eot(fmOpts))
    .use(Fontmin.ttf2woff(fmOpts))
    .use(Fontmin.ttf2svg(fmOpts))
    .use(Fontmin.css(fmOpts))
    .use(dump(fmOpts))
    .dest(dest || 'output')
    .run((err, files, stream) => {

        if (err) {
            log(err);
            process.exit(1);
        }

        files.forEach(file => {
github junmer / icon-font / source.js View on Github external
return fs.statSync(path).isFile();
    }
    catch (err) {
        return false;
    }
};

if (src.length > 1 && !isFile(src[src.length - 1])) {
    dest = src[src.length - 1];
    src.pop();
}

// start fontmin
new Fontmin()
    .src(src)
    .use(Fontmin.svgs2ttf(fmOpts.fontFamily, fmOpts))
    .use(Fontmin.ttf2eot(fmOpts))
    .use(Fontmin.ttf2woff(fmOpts))
    .use(Fontmin.ttf2svg(fmOpts))
    .use(Fontmin.css(fmOpts))
    .use(dump(fmOpts))
    .dest(dest || 'output')
    .run((err, files, stream) => {

        if (err) {
            log(err);
            process.exit(1);
        }

        files.forEach(file => {
            log(`created: ${file.path}`);
        });

fontmin

Minify font seamlessly, font subsetter, webfont (eot, woff, svg) converter.

MIT
Latest version published 6 months ago

Package Health Score

61 / 100
Full package analysis