Friday 17 March 2017

Custom SVG font

I'm trying to build my own font and everything works fine when I use command line but I need to associate 1 unicode point per icon and I'm unable to do this in command line, so I tryed the nodejs way.

I use svgicons2svgfont : https://github.com/nfroidure/svgicons2svgfont

var svgicons2svgfont = require('svgicons2svgfont');
var fs = require('fs');
var fontStream = svgicons2svgfont({
  fontName: 'hello'
});

// Setting the font destination
fontStream.pipe(fs.createWriteStream('fonts/hello.svg'))
  .on('finish',function() {
    console.log('Font successfully created!')
  })
  .on('error',function(err) {
    console.log(err);
  });

var files = [{
    path : '/path/to/icon1.svg',
    unicode : '????'
}];

for(var i = 0; < files.length; i++) {
    var glyph = fs.createReadStream(files[i].path);

    glyph.metadata = {
        unicode: [files[i].unicode],
        name: 'icon'+i
    };

    fontStream.write(glyph);
}

fontStream.end();

But in this case, I don't understand how to generate the unicode points.

1°) How can I generate a list of 3000+ points ? I will store this list and when adding new icon, select one of the available.

2°) What I have to write in CSS file, the property : content:"????"

Thanks !



via user3763667

No comments:

Post a Comment