# @tenado/svg2font

> 根据svg生成字体图标库，可以内置在项目中的脚手架工具

Latest version **1.0.13** (published 2024-09-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install @tenado/svg2font
pnpm add @tenado/svg2font
yarn add @tenado/svg2font
bun add @tenado/svg2font
```

Provides the command `svg2font`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2024-09-03 |
| First published | 2022-08-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 21.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | tenado |
| Keywords | svg, icon, font |

## Links

- npm: https://www.npmjs.com/package/@tenado/svg2font
- Repository: https://github.com/tenadolanter/svg2font
- Homepage: https://github.com/tenadolanter/svg2font#readme
- Issues: https://github.com/tenadolanter/svg2font/issues
- npm.io page: https://npm.io/package/@tenado/svg2font

## Dependencies (12)

- [ejs](https://npm.io/package/ejs.md) ^3.1.8
- [open](https://npm.io/package/open.md) ^7.4.2
- [chalk](https://npm.io/package/chalk.md) ^4.1.1
- [express](https://npm.io/package/express.md) ^4.18.1
- [svg2ttf](https://npm.io/package/svg2ttf.md) ^6.0.3
- [ttf2eot](https://npm.io/package/ttf2eot.md) ^3.0.0
- [inquirer](https://npm.io/package/inquirer.md) ^6.5.2
- [prettier](https://npm.io/package/prettier.md) ^2.8.8
- [ttf2woff](https://npm.io/package/ttf2woff.md) ^3.0.0
- [commander](https://npm.io/package/commander.md) ^7.2.0
- [ttf2woff2](https://npm.io/package/ttf2woff2.md) ^4.0.4
- [svgicons2svgfont](https://npm.io/package/svgicons2svgfont.md) ^10.0.5

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [stockfish](https://npm.io/package/stockfish.md) — 27.0K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads

## Recent versions

- 1.0.13 (latest) — 2024-09-03
- 1.0.12 — 2024-08-30
- 1.0.11 — 2023-11-01
- 1.0.10 — 2023-10-20
- 1.0.9 — 2023-10-20
- 1.0.7 — 2023-10-20
- 1.0.8 — 2023-10-19
- 1.0.6 — 2022-12-09
- 1.0.5 — 2022-12-09
- 1.0.3 — 2022-12-09
- 1.0.4 — 2022-12-09
- 1.0.2 — 2022-08-31
- 1.0.1 — 2022-08-15
- 1.0.0 — 2022-08-15

## README

## 介绍

svg2font, 根据 svg 生成字体图标库，可以内置在项目中的脚手架工具

## 使用

### 1、安装

```text
# 安装依赖
npm install @tenado/svg2font -D

或

yarn add @tenado/svg2font -D
```

### 2、初始化

执行如下命令，会在项目目录下生成一个`svg2font.config.js`文件，里面记录了脚本执行时候需要的配置

```bash
npx svg2font init
```

### 3、配置 svg2font.config.js

| 参数        | 说明                                                                   | 默认值     | 是否可选 |
| ----------- | ---------------------------------------------------------------------- | ---------- | -------- |
| inputPath   | svg 文件夹路径                                                         | ~          | 必填     |
| outputPath  | 生成字体文件存放位置                                                   | ~          | 必填     |
| fontFamily  | 字体的名称                                                             | tenadoIcon | 可选     |
| fontPrefix  | 字体的前缀                                                             | ticon-     | 可选     |
| ejs         | 生成 icon 列表页面的模板，默认使用系统的，如果需要自定义，则设置该选项 | ~          | 可选     |
| examplePath | 生成静态文件存放的位置，位置应与 outputPath 在同一目录下               | ~          | 可选     |
| examplePort | 查看静态文件的端口                                                     | ~          | 可选     |
| exampleRun  | 是否启动 example 的静态页面                                            | true       | 可选     |

svg2font.config.js 的默认配置如下：

```json
{
  "inputPath": "src/assets/svgs",
  "outputPath": "src/assets/font",
  "fontFamily": "tenadoIcon",
  "fontPrefix": "ticon-"
}
```

### 4、转换 svg 成字体文件

```bash
npx svg2font sync
```

### 5、项目 main 文件中引入字体文件 css

```js
// src/main.js
import "./src/assets/font/index.min.css";
```

### 6、在项目中使用字体图标

使用 `i` 或者 `span` 标签，且把 svg 名称作为类名，例如`<span class="ticon-color-pick"></span>`

### 7、查看当前项目的 icon 列表

更改配置文件 svg2font.config.js，向里面加入 examplePath 和 examplePort，这里注意 examplePath 应尽量与 outputPath 在同一目录下

```bash
npx svg2font example
```

---
_Source: https://npm.io/package/@tenado/svg2font · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
