update at 2026-02-09 16:09:44

This commit is contained in:
douboer
2026-02-09 16:09:44 +08:00
parent ffb7367d3a
commit 917f210dae
20 changed files with 790 additions and 184 deletions

View File

@@ -2,7 +2,7 @@
`apiserver/` 提供微信小程序用的远端渲染接口:
- 小程序只上传参数(字体 ID、文字、字号、颜色等
- 服务端读取 `fonts.json` + `fonts/`,生成 SVG/PNG 后返回
- 服务端读取字体清单 + 字体目录,生成 SVG/PNG 后返回
## 1. 启动
@@ -17,10 +17,10 @@ python3 apiserver/server.py \
其中 `--static-root` 目录必须包含:
- `fonts.json`
- `fonts/`(字体文件目录
- `fonts/`(统一字体目录)
- `miniprogram/assets/fonts.json`(小程序清单
如果不传 `--manifest`,默认读取 `<static-root>/fonts.json`
如果不传 `--manifest`,默认优先读取 `<static-root>/miniprogram/assets/fonts.json`,不存在时回退到 `<static-root>/fonts.json`
## 2. API
@@ -34,7 +34,7 @@ python3 apiserver/server.py \
```json
{
"fontId": "其他字体/AlimamaDaoLiTi",
"fontId": "0001",
"text": "星程字体转换",
"fontSize": 120,
"fillColor": "#000000",
@@ -54,7 +54,7 @@ python3 apiserver/server.py \
{
"ok": true,
"data": {
"fontId": "其他字体/AlimamaDaoLiTi",
"fontId": "0001",
"fontName": "AlimamaDaoLiTi",
"width": 956.2,
"height": 144.3,
@@ -100,7 +100,7 @@ sudo systemctl status font2svg-api
## 5. 约束
- 字体解析完全基于 `fonts.json``fontId` 必须存在。
- 字体解析完全基于字体清单(默认 `miniprogram/assets/fonts.json`),字体文件统一从 `<static-root>/fonts/` 读取`fontId` 必须存在。
- 服务端启用 CORS允许小程序访问。
- 不依赖 Flask/FastAPI使用 Python 标准库 HTTP 服务。
- `/api/render-png` 依赖 `node + sharp`(使用 `apiserver/svg_to_png.js` 转换)。