Files
font2pic/README.md
2026-02-07 16:05:38 +08:00

84 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# font2svg
本仓库提供两条能力链路:
- Web 应用(`frontend/`):本地字体预览、多字体对比、导出 `SVG/PNG`
- Python CLI根目录脚本图片转 SVG、字体文本转 SVG
## 文档导航
- 项目总览:`README.md`
- 详细设计:`DETAIL-DESIGN.md`
- 使用说明:`USAGE.md`
- 迭代计划:`PLAN.md`
- 前端子项目说明:`frontend/README.md`
## 核心特性
- 字体树 + 分类折叠 + 搜索 + 收藏
- 预览勾选与导出勾选分离,支持全选/全不选
- 文本自动按每行 45 字换行(保留手动换行)
- 预览采用分批加载与并发渲染,降低大字体库卡顿
- 导出 `SVG``PNG`,多项自动打包 ZIP
- 字体来源统一为 `frontend/public/fonts/`
## 目录结构
```text
font2svg/
├── frontend/ # Vue3 + TS Web 应用
│ ├── public/
│ │ ├── fonts/ # 字体唯一来源目录
│ │ └── fonts.json # 字体清单(脚本生成)
│ └── src/
├── scripts/
│ └── generate-font-list.py # 生成 frontend/public/fonts.json
├── font2svg.py # 字体文本转 SVGPython CLI
├── pic2svg.py # 图片转 SVGPython CLI
└── DETAIL-DESIGN.md # 详细设计
```
## 环境要求
- Node.js `>=18`
- pnpm `>=8`
- Python `>=3.9`
- 可选potrace`pic2svg.py` 需要
## 快速开始Web
```bash
pnpm -C frontend install
pnpm run prepare-fonts
pnpm run dev
```
默认访问地址:`http://localhost:5174`
## 常用命令
```bash
# 根目录
pnpm run dev
pnpm run build
pnpm run preview
pnpm run prepare-fonts
# 前端子项目
pnpm -C frontend run dev
pnpm -C frontend run build
pnpm -C frontend run preview
```
## Python CLI 概览
```bash
# 字体转 SVG
python font2svg.py --font path/to/font.ttf --text "你好"
# 图片转 SVG
python pic2svg.py images/your_image.png --outdir output
```
详细参数请看 `USAGE.md`