How to use the fontmin.otf2ttf function in fontmin

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 aui / font-spider / src / compressor / index.js View on Github external
var types = {
            'embedded-opentype': 'ttf2eot',
            'woff': 'ttf2woff',
            'woff2': 'ttf2woff2',
            'svg': 'ttf2svg'
        };


        fontmin.use(Fontmin.glyph({
            trim: false,
            text: webFont.chars || '#' // 传入任意字符避免 fontmin@0.9.5 BUG
        }));


        if (source.format === 'opentype') {
            fontmin.use(Fontmin.otf2ttf());
        }


        webFont.files.forEach(function(file) {
            var format = file.format;
            var fn = types[format];
            var extname = path.extname(file.url);
            var basename = path.basename(file.url, extname);
            var relative = path.relative(dirname, file.url);

            paths[extname] = {
                file: file,
                dirname: path.dirname(relative),
                basename: basename,
                extname: extname
            };
github dmnsgn / frontend-boilerplate / boilerplate / tasks / styles.js View on Github external
export function generateFonts(done) {
  const fontmin = new Fontmin()
    .src(`${config.src}/styles/fonts/*.{ttf,otf}`)
    .use(Fontmin.otf2ttf({
      clone: true
    }))
    .use(Fontmin.ttf2eot({
      clone: true
    }))
    .use(Fontmin.ttf2woff({
      clone: true
    }))
    .use(Fontmin.ttf2svg({
      clone: true
    }))
    .dest(`${config.dist}/styles/fonts`);

  return fontmin.run((err) => {
    if (err) {
      console.log(err);
github telus / tds-core / core / scripts / icons.js View on Github external
job.run(function (err, files) {
      if (err) {
	reject(err);
      } else {
	resolve(files);
      }
    });
  });
}

/**
 * Convert the source OTF to TTF
 * Auto-hint the TTF
 * Convert the TTF to EOT and WOFF
 */
runFontminJob(new Fontmin().src(otfPath).dest(destPath).use(Fontmin.otf2ttf()))
  .then(function (files) {
    if (files.length !== 1) {
      throw 'Unable to find generated TTF webfont';
    } else {
      return applyAutohinting(files[0].path);
    }
  })
  .then(function (hintedTtf) {

    var input = fs.readFileSync(hintedTtf);
    fs.writeFileSync('fonts/core-icons.woff2', ttf2woff2(input));

    return Promise.all([
      runFontminJob(new Fontmin().src(hintedTtf).dest(destPath).use(Fontmin.ttf2eot())),
      runFontminJob(new Fontmin().src(hintedTtf).dest(destPath).use(Fontmin.ttf2woff()))
    ])

fontmin

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

MIT
Latest version published 1 month ago

Package Health Score

71 / 100
Full package analysis