# SVG2Iconfont **Repository Path**: wiszsw/SVG2Iconfont ## Basic Information - **Project Name**: SVG2Iconfont - **Description**: SVG转Iconfont工具 - **Primary Language**: JavaScript - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2021-02-08 - **Last Updated**: 2021-02-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SVG2Iconfont 将 SVG 图标文件转换为 SVG、TTF、WOFF、WOFF2、EOT 字体文件的工具。 Node 版本:>10.16.0 ## 安装 ```sh npm install @wings-j/svg2iconfont ``` ## 使用 **命令行** 1. `npm i` 2. `npm link` 3. `svg2iconfont` 参数: `--name `:字体名称。默认为`iconfont`。
`--input `:输入目录。默认为`./`。
`--output `:输出目录。默认为`./`。
`--format `:字体格式。默认 为`svg,ttf,woff2,woff,eot`。可选 svg、ttf、woff2、 woff 和 eot,用逗号分隔。
`--prefix `:CSS 类前缀。默认为空。
示例: ```sh svg2iconfont --name iconfont --input ./svg --output ./font --format svg,ttf,woff2,woff,eot --prefix iconfont- ``` 注意: CSS 类前缀不局限于一个名字,因为它是直接被添加到 CSS 类之前,它的替换方式是: ```css .%prefix%%class%::before { content: ''; } ``` 其中%prefix%被前缀替换,%class%被类名即 SVG 图标文件的文件名替换。比如一个类名为 A,前缀为 B-,那么在使用时为`class="B-A"`。前缀也可以是 B.那么在使用时为`class="B A"`。 **模块调用** 入口文件地址:`dist/index.js`。 ```js import svg2iconfont from 'dist/index.js' svg2iconfont({ name, input, output, format, prefix }) ``` 参数: `name`:字符串。默认为`iconfont`。字体名称。
`input`:字符串。默认为`./`。输入目录。
`output`:字符串。默认为`./`。输出目录。
`format`:字符串数组。默认值 :`['svg', 'ttf', 'woff2' ,'woff' ,'eot']`。字体格式。
`prefix`:字符串。默认为空。CSS 类前缀。