fix(fonts): FONT_NAME_MAP改为Noto Sans SC适配容器实际字体 (#1514)
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 4m39s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 5m50s
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging API Image (push) Successful in 3m36s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 3m35s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 4m18s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 4m24s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 5m9s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m30s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 8m41s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 5m15s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 2m21s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 3m22s
CI/CD Pipeline / Integration Tests (push) Successful in 3m37s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 4m17s
CI/CD Pipeline / Unit Tests (push) Successful in 13m18s
CI/CD Pipeline / Canary Release to Production (push) Failing after 494h21m29s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 494h21m30s
CI/CD Pipeline / Build Production Web Image (push) Failing after 494h21m31s
CI/CD Pipeline / Production Browser E2E (push) Failing after 494h21m29s
CI/CD Pipeline / CI Gate (push) Failing after 494h21m31s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 494h33m38s
CI/CD Pipeline / PR Build API Image (push) Failing after 494h33m40s
CI/CD Pipeline / Frontend Lint (push) Failing after 494h34m22s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 494h37m57s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 494h43m11s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 494h43m24s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 494h43m26s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Failing after 494h45m10s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 494h45m11s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 494h45m16s
CI/CD Pipeline / Deploy Production (push) Failing after 494h55m28s
CI/CD Pipeline / Build Production API Image (push) Failing after 494h55m29s
CI/CD Pipeline / PR Build Web Image (push) Failing after 495h7m38s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 495h19m11s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 4m39s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 5m50s
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging API Image (push) Successful in 3m36s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 3m35s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 4m18s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 4m24s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 5m9s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m30s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 8m41s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 5m15s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 2m21s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 3m22s
CI/CD Pipeline / Integration Tests (push) Successful in 3m37s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 4m17s
CI/CD Pipeline / Unit Tests (push) Successful in 13m18s
CI/CD Pipeline / Canary Release to Production (push) Failing after 494h21m29s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 494h21m30s
CI/CD Pipeline / Build Production Web Image (push) Failing after 494h21m31s
CI/CD Pipeline / Production Browser E2E (push) Failing after 494h21m29s
CI/CD Pipeline / CI Gate (push) Failing after 494h21m31s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 494h33m38s
CI/CD Pipeline / PR Build API Image (push) Failing after 494h33m40s
CI/CD Pipeline / Frontend Lint (push) Failing after 494h34m22s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 494h37m57s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 494h43m11s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 494h43m24s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 494h43m26s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Failing after 494h45m10s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 494h45m11s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 494h45m16s
CI/CD Pipeline / Deploy Production (push) Failing after 494h55m28s
CI/CD Pipeline / Build Production API Image (push) Failing after 494h55m29s
CI/CD Pipeline / PR Build Web Image (push) Failing after 495h7m38s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 495h19m11s
This commit was merged in pull request #1514.
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 = "这是一段非常长的标题文字用于测试自动换行功能是否正常工作"
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user