Compare commits

...

1 Commits

Author SHA1 Message Date
xiaoxia f700e38876 fix(fonts): FONT_NAME_MAP改为Noto Sans SC适配容器实际字体
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2m41s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 3m53s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m16s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m39s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 4m49s
AI Code Review / AI Code Review (pull_request) Successful in 4m58s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 5m14s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m33s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 6m25s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 10m40s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 13m7s
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 5m21s
CI/CD Pipeline / CI Gate (pull_request) Successful in 29s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 3m53s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 5m11s
容器内 NotoSansCJK ttc 已被移除,仅剩 NotoSansSC-VF.ttf,
注册名为 'Noto Sans SC'。fc-match 'Noto Sans CJK SC' 会回退到
DejaVu Sans 导致中文渲染异常。

- ass_subtitle_builder: 思源黑体/苹方/PingFang/微软雅黑/华康俪金黑
  全部映射为 'Noto Sans SC'
- title_overlay: _FONT_CANDIDATES 优先查找 NotoSansSC-VF.ttf
- 同步更新相关单测断言
2026-08-27 00:18:30 +08:00
6 changed files with 37 additions and 31 deletions
+25 -18
View File
@@ -26,13 +26,13 @@ TITLE_MARGIN_SIDE = 40
# 字体名称映射:前端中文字体名 → 服务器实际注册名(ffmpeg/ASS 通过注册名匹配字体)
FONT_NAME_MAP: dict[str, str] = {
"思源黑体": "Noto Sans CJK SC",
"思源黑体": "Noto Sans SC",
"思源宋体": "Noto Serif CJK SC",
"苹方": "Noto Sans CJK SC",
"PingFang": "Noto Sans CJK SC",
"微软雅黑": "Noto Sans CJK SC",
"苹方": "Noto Sans SC",
"PingFang": "Noto Sans SC",
"微软雅黑": "Noto Sans SC",
"楷体": "Noto Serif CJK SC",
"华康俪金黑": "Noto Sans CJK SC",
"华康俪金黑": "Noto Sans SC",
}
@@ -191,7 +191,6 @@ def format_ass_time(seconds: float) -> str:
# ── 完整 ASS 内容生成 ─────────────────────────────────────────────────────────
def _wrap_title_text(
text: str,
video_width: int,
@@ -282,20 +281,28 @@ def build_ass_content(
if title_config:
_stroke_val = title_config.get("stroke")
if isinstance(_stroke_val, bool):
title_config["stroke"] = {
"enabled": _stroke_val,
"color": "#000000",
"width": 2,
} if _stroke_val else {"enabled": False}
title_config["stroke"] = (
{
"enabled": _stroke_val,
"color": "#000000",
"width": 2,
}
if _stroke_val
else {"enabled": False}
)
_shadow_val = title_config.get("shadow")
if isinstance(_shadow_val, bool):
title_config["shadow"] = {
"enabled": _shadow_val,
"color": "#000000",
"blur": 4,
"offset_x": 2,
"offset_y": 2,
} if _shadow_val else {"enabled": False}
title_config["shadow"] = (
{
"enabled": _shadow_val,
"color": "#000000",
"blur": 4,
"offset_x": 2,
"offset_y": 2,
}
if _shadow_val
else {"enabled": False}
)
title_enabled = title_config.get("enabled", True) and bool(title_text.strip())
subtitle_enabled = subtitle_config.get("enabled", True) and bool(subtitle_text.strip())
+1
View File
@@ -15,6 +15,7 @@ logger = logging.getLogger(__name__)
# 按优先级查找 CJK 字体(Debian/Ubuntu fonts-noto-cjk 安装路径)
_FONT_CANDIDATES = (
"/usr/share/fonts/opentype/noto/NotoSansSC-VF.ttf",
"/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc",
"/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",
"/usr/share/fonts/truetype/noto/NotoSansCJK-Bold.ttc",
+8 -10
View File
@@ -79,7 +79,7 @@ class TestBuildAssStyle:
def test_minimal_style(self):
result = build_ass_style("TestStyle")
assert result.startswith("Style: TestStyle,")
assert "Noto Sans CJK SC" in result
assert "Noto Sans SC" in result
assert ",48," in result
def test_custom_font_size(self):
@@ -152,21 +152,20 @@ class TestBuildAssStyle:
# Style: 行有 23 个字段(去掉 "Style: " 前缀后)
assert len(parts) == 23
def test_font_name_mapping_siyuan(self):
"""思源黑体 → Noto Sans CJK SC"""
"""思源黑体 → Noto Sans SC"""
result = build_ass_style("Test", font_name="思源黑体")
assert "Noto Sans CJK SC" in result
assert "Noto Sans SC" in result
def test_font_name_mapping_apple(self):
"""苹方 → Noto Sans CJK SC"""
"""苹方 → Noto Sans SC"""
result = build_ass_style("Test", font_name="苹方")
assert "Noto Sans CJK SC" in result
assert "Noto Sans SC" in result
def test_font_name_mapping_msyh(self):
"""微软雅黑 → Noto Sans CJK SC"""
"""微软雅黑 → Noto Sans SC"""
result = build_ass_style("Test", font_name="微软雅黑")
assert "Noto Sans CJK SC" in result
assert "Noto Sans SC" in result
def test_font_name_mapping_unknown_passthrough(self):
"""未映射字体原样使用"""
@@ -174,7 +173,6 @@ class TestBuildAssStyle:
assert "CustomFont" in result
# ── 文本转义 ──────────────────────────────────────────────────────────────────
@@ -483,6 +481,7 @@ class TestConstants:
def test_title_margin_side(self):
assert TITLE_MARGIN_SIDE == 40
# ── 标题自动换行 ──────────────────────────────────────────────────────────────
@@ -554,7 +553,6 @@ class TestWrapTitleText:
assert result == text
assert result.count("\\N") == 2
def test_build_ass_content_integration(self):
"""集成测试:build_ass_content 中的标题应该自动换行。"""
long_title = "这是一段非常长的标题文字用于测试自动换行功能是否正常工作"
+1 -1
View File
@@ -80,7 +80,7 @@ class TestBuildAssStyle:
def test_basic_style(self):
style = _build_ass_style("Default")
assert style.startswith("Style: Default,")
assert "Noto Sans CJK SC" in style
assert "Noto Sans SC" in style
assert "48" in style # font_size
def test_custom_font(self):
+1 -1
View File
@@ -84,7 +84,7 @@ class TestBuildAssStyle:
"""基本样式行包含关键字段."""
line = _build_ass_style("Default")
assert line.startswith("Style: Default,")
assert "Noto Sans CJK SC" in line
assert "Noto Sans SC" in line
assert "48" in line # font_size
def test_bold_enabled(self):
+1 -1
View File
@@ -230,7 +230,7 @@ class TestFullStyleConsistency:
fields = [f.strip() for f in style_line.split(",")]
# Fontname
assert fields[1] == "Noto Sans CJK SC"
assert fields[1] == "Noto Sans SC"
# Fontsize = 28
assert fields[2] == "28"
# Bold = -1 (True)