fix: ASS Fontname 字体名称映射到服务器注册名 (#1508)
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 56s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 1m30s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 2m42s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 3m1s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 2m18s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 3m54s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 3m8s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m34s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m44s
AI Code Review / AI Code Review (pull_request) Failing after 4m8s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 29s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m0s
CI/CD Pipeline / Build Staging API Image (push) Successful in 7m20s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 7m49s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 46s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 53s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m14s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 10m17s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 10m19s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m3s
CI/CD Pipeline / Unit Tests (push) Failing after 14m3s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 12m14s
CI/CD Pipeline / Integration Tests (push) Successful in 5m10s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 5m18s
CI/CD Pipeline / CI Gate (pull_request) Failing after 6s
CI/CD Pipeline / CI Gate (push) Failing after 502h14m20s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 502h14m28s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 502h14m32s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 502h14m29s
CI/CD Pipeline / Production Browser E2E (push) Failing after 502h15m42s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 502h14m30s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 502h14m31s
CI/CD Pipeline / Build Production Web Image (push) Failing after 502h15m46s
CI/CD Pipeline / Build Production API Image (push) Failing after 502h15m46s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 502h23m20s
CI/CD Pipeline / Canary Release to Production (push) Failing after 502h15m44s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 502h23m23s
CI/CD Pipeline / Deploy Production (push) Failing after 502h15m44s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 502h23m25s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 502h26m44s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 502h26m46s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Failing after 502h26m49s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 502h27m30s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 502h27m34s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 502h28m29s
CI/CD Pipeline / PR Build API Image (push) Failing after 502h28m34s
CI/CD Pipeline / Frontend Lint (push) Failing after 502h29m51s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 502h29m51s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 502h48m27s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 502h49m41s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 502h57m17s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 502h57m30s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 503h1m28s
CI/CD Pipeline / PR Build Web Image (push) Failing after 503h2m27s

Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
This commit was merged in pull request #1508.
This commit is contained in:
2026-08-26 16:56:01 +08:00
committed by auto-approve-bot
parent bd0082b764
commit 23b6f23bad
2 changed files with 38 additions and 2 deletions
+15 -1
View File
@@ -24,6 +24,17 @@ TITLE_MARGIN_TOP = 120
TITLE_MARGIN_BOTTOM = 60
TITLE_MARGIN_SIDE = 40
# 字体名称映射:前端中文字体名 → 服务器实际注册名(ffmpeg/ASS 通过注册名匹配字体)
FONT_NAME_MAP: dict[str, str] = {
"思源黑体": "Noto Sans CJK SC",
"思源宋体": "Noto Serif CJK SC",
"苹方": "Noto Sans CJK SC",
"PingFang": "Noto Sans CJK SC",
"微软雅黑": "Noto Sans CJK SC",
"楷体": "Noto Serif CJK SC",
"华康俪金黑": "Noto Sans CJK SC",
}
# ── 颜色转换 ──────────────────────────────────────────────────────────────────
@@ -117,6 +128,9 @@ def build_ass_style(
bold_val = -1 if bold else 0
italic_val = -1 if italic else 0
# 字体名称映射:前端中文字体名 → 服务器注册名,未命中则原样使用
actual_font = FONT_NAME_MAP.get(font_name, font_name)
# BackColour 用于阴影(BorderStyle=1 时 outline + shadow)
back_color = primary_color
@@ -124,7 +138,7 @@ def build_ass_style(
shadow_depth = shadow_offset[1] if shadow_blur > 0 else 0
return (
f"Style: {style_name},{font_name},{font_size},{primary_color},"
f"Style: {style_name},{actual_font},{font_size},{primary_color},"
f"&H000000FF,{outline_color},{back_color},"
f"{bold_val},{italic_val},0,0,100,100,0,0,"
f"1,{outline_width},{shadow_depth},{alignment},"
+23 -1
View File
@@ -79,7 +79,7 @@ class TestBuildAssStyle:
def test_minimal_style(self):
result = build_ass_style("TestStyle")
assert result.startswith("Style: TestStyle,")
assert "思源黑体" in result
assert "Noto Sans CJK SC" in result
assert ",48," in result
def test_custom_font_size(self):
@@ -153,6 +153,28 @@ class TestBuildAssStyle:
assert len(parts) == 23
def test_font_name_mapping_siyuan(self):
"""思源黑体 → Noto Sans CJK SC"""
result = build_ass_style("Test", font_name="思源黑体")
assert "Noto Sans CJK SC" in result
def test_font_name_mapping_apple(self):
"""苹方 → Noto Sans CJK SC"""
result = build_ass_style("Test", font_name="苹方")
assert "Noto Sans CJK SC" in result
def test_font_name_mapping_msyh(self):
"""微软雅黑 → Noto Sans CJK SC"""
result = build_ass_style("Test", font_name="微软雅黑")
assert "Noto Sans CJK SC" in result
def test_font_name_mapping_unknown_passthrough(self):
"""未映射字体原样使用"""
result = build_ass_style("Test", font_name="CustomFont")
assert "CustomFont" in result
# ── 文本转义 ──────────────────────────────────────────────────────────────────