Socket
Socket
Sign inDemoInstall

svgicons2svgfont

Package Overview
Dependencies
2
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

svgicons2svgfont


Version published
Maintainers
1
Install size
888 kB
Created

Package description

What is svgicons2svgfont?

The svgicons2svgfont npm package is a tool that converts a set of SVG icons into a single SVG font. This is useful for creating icon fonts that can be used in web development, allowing for scalable and customizable icons.

What are svgicons2svgfont's main functionalities?

Convert SVG icons to SVG font

This feature allows you to convert a directory of SVG icons into a single SVG font file. The code sample demonstrates how to read SVG files from a directory, create a font stream, and write the resulting SVG font to a file.

const fs = require('fs');
const SVGIcons2SVGFontStream = require('svgicons2svgfont');

const fontStream = new SVGIcons2SVGFontStream({
  fontName: 'myfont'
});

fontStream.pipe(fs.createWriteStream('myfont.svg'))
  .on('finish', () => {
    console.log('Font successfully created!');
  })
  .on('error', (err) => {
    console.error(err);
  });

fs.readdirSync('icons').forEach(file => {
  const glyph = fs.createReadStream(`icons/${file}`);
  glyph.metadata = { unicode: [String.fromCharCode(0xe001 + i)], name: file.replace('.svg', '') };
  fontStream.write(glyph);
});

fontStream.end();

Other packages similar to svgicons2svgfont

Changelog

Source

11.0.0 (2022-05-28)

Bug Fixes

  • core: fix the metapak setup (66a6274)
  • deps: remove unused dependencies, move devDependencies where they belong to (ecc3d87)

<a name="10.0.6"></a>

Readme

Source

svgicons2svgfont Build Status

svgicons2svgfont is a simple tool to merge multiple icons to an SVG font.

'rect', 'line', 'circle', 'ellipsis', 'polyline' and 'polygon' shapes will be converted to pathes. Multiple pathes will be merged.

Transform attributes either on 'g' element or path/shapes elements are currently unsupported.

## Usage NodeJS module:

var svgicons2svgfont = require('svgicons2svgfont')
  , fs = require('fs');
  , fontStream = svgicons2svgfont([
    'icons/directory/icon1.svg',
    'icons/directory/icon2.svg'
  ], options);

// Saving in a file
fontStream.pipe(fs.createWriteStream('font/destination/file.svg'))
  .on('finish',function() {
    console.log('Font written !')
  });

CLI (install the module globally):

svgicons2svgfont icons/directory font/destination/file.svg

Options (not plugged to CLI yet)

fontName : String

The font family name you want (defaults to 'iconfont').

fixedWidth : Boolean

Creates a monospace font of the width of the largest input icon (defaults to false).

fontHeight : Boolean

The ouputted font height (defaults to the height of the highest input icon).

descent : Number

The font descent (defaults to 0). It is usefull to fix the font baseline yourself.

The ascent formula is : ascent = fontHeight - descent.

Grunt plugin:

npm install grunt-svgicons2svgfont

Contributing

Feel free to pull your code if you agree with publishing under the MIT license.

Keywords

FAQs

Last updated on 22 Jan 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc