D
D
Danya Wyse2021-12-21 21:51:32
Fonts
Danya Wyse, 2021-12-21 21:51:32

How to convert fonts using GULP assembler?

There is such a collector https://github.com/iWyse/gulpbind
I can not find a working module which is usually called fontStyle to convert fonts and make a separate file. Who can help figure it out?
Now font.js looks like this

const font = cb => {
  return $.gulp.src($.path.font.src)
    .pipe($.gp.plumber({
      errorHandler: $.gp.notify.onError(error => ({
        title: "Font",
        message: error.message
      }))
    }))
    .pipe($.gp.newer($.path.font.dest))
    .pipe($.gp.fonter($.app.fonter))
    .pipe($.gulp.dest($.path.font.dest))
    .pipe($.gp.ttf2woff2())
    .pipe($.gulp.dest($.path.font.dest));
}

module.exports = font;


Approximately such a constant should be to create a file with fonts
const cb = () => { };
let srcFonts = './src/scss/basic/_fonts.scss';
let appFonts = './app/fonts/';
const fontsStyle = (done) => {
   let file_content = fs.readFileSync(srcFonts);
   fs.writeFile(srcFonts, '', cb);
   fs.readdir(appFonts, function (err, items) {
      if (items) {
         let c_fontname;
         for (var i = 0; i < items.length; i++) {
            let fontname = items[i].split('.');
            fontname = fontname[0];
            if (c_fontname != fontname) {
               fs.appendFile(srcFonts, '@include font("' + fontname + '", "' + fontname + '", 400, "normal");\r\n', cb);
            }
            c_fontname = fontname;
         }
      }
   });
   done();

};

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question