https://github.com/2234839/web-font
字体裁剪工具
https://github.com/2234839/web-font
fontmin ttf web-font
Last synced: 2 months ago
JSON representation
字体裁剪工具
- Host: GitHub
- URL: https://github.com/2234839/web-font
- Owner: 2234839
- Created: 2020-03-20T05:19:32.000Z (about 5 years ago)
- Default Branch: new
- Last Pushed: 2024-09-17T19:31:15.000Z (9 months ago)
- Last Synced: 2024-10-14T07:36:51.725Z (8 months ago)
- Topics: fontmin, ttf, web-font
- Language: TypeScript
- Homepage: https://webfont.shenzilong.cn
- Size: 34.2 MB
- Stars: 268
- Watchers: 6
- Forks: 20
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# web font 字体裁剪工具
之前的版本请查看 master 分支,为了能使用 llrt ,我进行了重写,之后只维护此分支

上面的内存占用是空载状态下,在执行字体裁剪时会将字体加载到内存中,所以会占用更多的内存,不过 llrt 也具有 gc 功能,在内存不够用时会自动释放。
虽然 llrt 内存占用低,但它运行速度慢,不到node的1/2。有运行速度要求的建议使用node/bun运行## 起因
ui 需要展现一些特定的字体,但直接引入字体包又过大,于是想到了裁剪字体,一开始想的使用「字蛛」但他是针对静态网站的,而且实际他会多出许多英文的,估计是直接将源码中存在的文字都算进去了。后来又找到阿里的「webfont」 但他的字体有限,项目又不开源,所以自己写了这个
## 在线尝试
- [web font 在线站点](https://webfont.shenzilong.cn/)
## 目的与功能
1.裁剪字体包使其仅包含选中的字体,其体积自然十分之小
2.另外可以生成 css 直接复制可用,部署在公网便可永久访问## 安装与使用
### 使用 node / tjs / llrt 等运行时
拉取项目,并将字体文件放到项目内的 font 目录下,然后运行:
pnpm install && pnpm build && pnpm build_backend
node ./dist_backend/app.cjs
llrt ./dist_backend/app.cjs
tjs run ./dist_backend/app.cjs### 使用 docker 安装
此镜像使用 llrt 运行时
https://hub.docker.com/repository/docker/llej0/web-font 很小的包体积 
docker compoose.yml
```yml
version: '3'
services:
app:
image: docker.io/llej0/web-font:latest
ports:
- "8087:8087"
volumes:
- ./data:/home/font # 挂载本机字体目录
deploy:
resources:
limits:
memory: 900M # 设置内存限制为900MB,根据实际需求来设置
restart: on-failure # 设置重启策略为 on-failure```
其中 font 目录替换成你的字体文件存放目录
## 提供的服务
## 鸣谢
[kekee000/fonteditor-core](https://github.com/kekee000/fonteditor-core)
[字体天下](http://www.fonts.net.cn/commercial-free-32767/fonts-zh-1.html)
## License
MIT © [崮生](https://shenzilong.cn/关于/mit.html)