百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

svgicons2svgfont

> 编程语言
开源

连接 SVG 图标并输出 SVG 字体

363 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

连接 SVG 图标并输出 SVG 字体

svgicons2svgfont

Read a set of SVG icons and output a SVG font //: # (::contents:start)

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

In your scripts

…

Debugging

To debug, simply use the following env var: DEBUG=svgicons2svgfont.

CLI interface

All options are available except the log one by using this pattern: --{LOWER_CASE(optionName)}={optionValue}.

bash
svgicons2svgfont --fontName=hello -o font/destination/file.svg icons/directory/*.svg

Note that you won't be able to customize icon names or icons unicodes by passing options but by using the following convention to name your icons files: ${icon.unicode}-${icon.name}.svg where icon.unicode is a comma separated list of unicode strings (ex: 'uEA01,uE001,uE001uE002', note that the last string is in fact a ligature).

There is a few more options for the CLI interface, you can list all of them:

bash
npx svgicons2svgfont --help

Gives:

…

API

new SVGIcons2SVGFontStream(options)

options.fontName

Type: String Default value: 'iconfont'

The font family name you want.

options.fontId

Type: String Default value: the options.fontName value

The font id you want.

options.fontStyle

Type: String Default value: ''

The font style you want.

options.fontWeight

Type: String Default value: ''

The font weight you want.

options.fixedWidth

Type: Boolean Default value: false

Creates a monospace font of the width of the largest input icon.

options.centerHorizontally

Type: Boolean Default value: false

Calculate the bounds of a glyph and center it horizontally.

options.centerVertically

Type: Boolean Default value: false

Centers the glyphs vertically in the generated font.

options.normalize

Type: Boolean Default value: false

Normalize icons by scaling them to the height of the highest icon.

options.preserveAspectRatio

Type: Boolean Default value: false

Used with normalize to scale down glyph if the SVG width is greater than the height.

options.fontHeight

Type: Number Default value: MAX(icons.height) The outputted font height (defaults to the height of the highest input icon).

options.round

Type: Number Default value: 10e12 Setup SVG path rounding.

options.descent

Type: Number Default value: 0

The font descent. It is usefull to fix the font baseline yourself.

Warning: The descent is a positive value!

options.ascent

Type: Number Default value: fontHeight - descent

The font ascent. Use this options only if you know what you're doing. A suitable value for this is computed for you.

options.metadata

Type: String Default value: undefined

The font metadata. You can set any character data in but it is the be suited place for a copyright mention.

options.metadataProvider

Type: (file: string, cb: (err: any, metadata: {file: string, name: string, unicode: string[], renamed: boolean}) => void

Default value: require('svgicons2svgfont/src/metadata')(options)

A function which determines the metadata for an icon. It takes a parameter file with an icon svg and should return icon metadata (asynchronously) via the callback function. You can use this function to provide custom logic for svg to codepoint mapping.

metadata.path The path to the icon file. (The original file param is the file was not moved.)
metadata.name The name of the icon
metadata.unicode The unicode codepoints corresponding to this glyph. Each should be a 1-codepoint string.
metadata.renamed Wether the original file was moved (e.g. to prefix it with its unicode codepoint)

options.log

Type: Function Default value: console.log

Allows you to provide your own logging function. Set to function(){} to disable logging.

Build systems

Grunt plugins

grunt-svgicons2svgfont and grunt-webfont.

Gulp plugins

Try gulp-iconfont and gulp-svgicons2svgfont.

Stylus plugin

Use stylus-iconfont.

Mimosa plugin

Use mimosa-svgs-to-iconfonts.

CLI alternatives

You can combine this plugin's CLI interface with svg2ttf, ttf2eot, ttf2woff and ttf2woff2. You can also use webfonts-generator.

Stats

Contributing

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

License

MIT

Authors

  • Nicolas Froidure
  • Adrian Leonhard
  • Vinicius Teixeira

License

MIT

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言