How to use the fontmin.ttf2svg 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 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 / serve-fontmin / index.js View on Github external
// for css font path
        fmOpts.fontPath = ['.', opts.dest, ''].join('/');

        // font css font family
        fmOpts.fontFamily = font.name || font.basename;

        var stream = storage.src(font.srcPath)
            .pipe(Fontmin.glyph({
                text: font.text
            })())
            .pipe(streamRename({
                basename: font.hash
            }))
            .pipe(Fontmin.ttf2eot(fmOpts)())
            .pipe(Fontmin.ttf2woff(fmOpts)())
            .pipe(Fontmin.ttf2svg(fmOpts)())
            .pipe(Fontmin.css(fmOpts)())
            .pipe(storage.dest(opts.dest));

        stream.on('error', callback);
        stream.pipe(concat(callback.bind(null, null)));

    }
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);
    }
    done();
  });
}
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`)
    .use(Fontmin.ttf2eot({
      clone: true
    }))
    .use(Fontmin.ttf2woff({
      clone: true
    }))
    .use(Fontmin.ttf2svg({
      clone: true
    }))
    .dest(`${config.dist}/styles/fonts`);

  return fontmin.run(
    function(err, files, stream) {
      done();
      if (err) {
        console.log(err);
      }
    }
  );
}
github ecomfe / gulp-fontmin / index.js View on Github external
if (text && opts.chineseOnly) {
            text = text.replace(/[^\u4e00-\u9fa5]/g, '');
        }

        opts.text = text;

        var fontmin = new Fontmin()
            .src(file.contents)
            .use(rename({
                path: file.path
            }))
            .use(Fontmin.glyph(opts))
            .use(Fontmin.ttf2eot())
            .use(Fontmin.ttf2woff())
            .use(Fontmin.ttf2svg())
            .use(Fontmin.css(opts));

        if (opts.use) {
            opts.use.forEach(fontmin.use.bind(fontmin));
        }

        var fileStream = this;

        fontmin.run(function (err, files) {
            if (err) {
                cb(new gutil.PluginError('gulp-fontmin:', err, {fileName: file.path}));
                return;
            }

            var gulpFile;

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