Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
svgicons2svgfont
Advanced tools
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.
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();
The svg2ttf package converts SVG fonts to TTF (TrueType Font) format. While svgicons2svgfont focuses on creating SVG fonts from individual SVG icons, svg2ttf is used for converting those SVG fonts into TTF format, which is widely supported across different platforms.
Fontello is a tool that allows you to build custom icon fonts from a variety of icon sets. It provides a web interface for selecting icons and generating font files in various formats, including SVG, TTF, and WOFF. Unlike svgicons2svgfont, which is a command-line tool, Fontello offers a more user-friendly, graphical approach.
IcoMoon is another popular tool for creating custom icon fonts. It offers both a web app and a command-line tool for generating icon fonts from SVG icons. IcoMoon provides additional features such as icon set management and the ability to generate multiple font formats, making it a more comprehensive solution compared to svgicons2svgfont.
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 support is currenly experimental, report issues if any.
You can test this library with the frontend generator.
You may want to convert fonts to icons, if so use svgfont2svgicons.
## 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
Type: String
Default value: 'iconfont'
The font family name you want.
Type: Boolean
Default value: false
Creates a monospace font of the width of the largest input icon.
Type: Boolean
Default value: false
Calculate the bounds of a glyph and center it horizontally.
Warning: The bounds calculation is currently a naive implementation that may not work for some icons. We need to create a svg-pathdata-draw module on top of svg-pathdata to get the real bounds of the icon. It's in on the bottom of my to do, but feel free to work on it. Discuss it in the related issue.
Type: Boolean
Default value: false
Normalize icons by scaling them to the height of the highest icon.
Type: Number
Default value: MAX(icons.height)
The outputted font height (defaults to the height of the highest input icon).
Type: Number
Default value: 0
The font descent. It is usefull to fix the font baseline yourself.
Warning: The descent is a positive value!
The ascent formula is: ascent = fontHeight - descent.
Type: Function
Default value: false
Allows you to provide your own logging function. Set to function(){}
to
impeach logging.
grunt-svgicons2svgfont and grunt-webfont.
Try gulp-iconfont and gulp-svgicons2svgfont.
### Mimosa plugin
https://www.npmjs.org/package/mimosa-svgs-to-iconfonts
Feel free to push your code if you agree with publishing under the MIT license.
FAQs
Read a set of SVG icons and output a SVG font
The npm package svgicons2svgfont receives a total of 152,041 weekly downloads. As such, svgicons2svgfont popularity was classified as popular.
We found that svgicons2svgfont demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.