How to use the fontmin.ttf2woff 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 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 codexa / firetext / builder / build.js View on Github external
// Remove unused glyphs from icon font
			var rIconFontUrl = /(url\(".*?materialdesignicons-webfont.woff.*?base64,)(.*?)("\))/;
			var rIconRuleMatch = /\.icon-.*?:before {\n  content: "\\([\da-f]+)";\n}/g;
			var rIconRuleExtract = /\.icon-.*?:before {\n  content: "\\([\da-f]+)";\n}/; // not global
			
			window.language = 'en-US'; // Since there is a window, fontmin expects window.language
			
			var Fontmin = require('fontmin');
			var fontmin = new Fontmin()
				.src(argv._[0].replace(/[^\/]*\.html/, 'style/fonts/materialdesignicons-webfont.ttf'))
				.use(Fontmin.glyph({
					text: css.match(rIconRuleMatch).map(function(iconRule) {
						return String.fromCharCode(parseInt(iconRule.match(rIconRuleExtract)[1], 16));
					}).join(''),
				}))
				.use(Fontmin.ttf2woff({
					deflate: true // Does nothing but shouldn't hurt
				}));
			fontmin.run(function(err, files) {
				if(err) {
					throw err;
				}
				
				css = css.replace(rIconFontUrl,
					'$1' +
					files[0].contents.toString('base64') +
					'$3'
				);
				
				
				// Minify css
				css = require('more-css').compress(css);
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 telus / tds-core / core / scripts / icons.js View on Github external
.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()))
    ])
  })
  .catch(function (err) {
github ecomfe / gulp-fontmin / index.js View on Github external
var text = opts.text || '';

        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