This commit is contained in:
949036910@qq.com
2026-06-02 23:18:07 +08:00
parent 983d96ce7e
commit 7fa83f57b6
4 changed files with 42 additions and 5 deletions

View File

@@ -657,6 +657,19 @@ class AdvancedCoverGenerator:
title_text = self.config.get('title', self.template.get('titleText', '')) title_text = self.config.get('title', self.template.get('titleText', ''))
subtitle_text = self.template.get('subtitleText', '') subtitle_text = self.template.get('subtitleText', '')
titles_config = self.template.get('titles')
if titles_config and isinstance(titles_config, dict):
main_cfg = titles_config.get('main') or {}
sub_cfg = titles_config.get('sub') or {}
if main_cfg.get('text'):
title_text = main_cfg['text']
elif self.template.get('titleText'):
title_text = self.template.get('titleText')
if sub_cfg.get('text') is not None:
subtitle_text = sub_cfg.get('text') or ''
elif self.template.get('subtitleText') is not None:
subtitle_text = self.template.get('subtitleText') or ''
if not title_text and not subtitle_text: if not title_text and not subtitle_text:
print("Step 5: No title or subtitle text, skipping", file=sys.stderr) print("Step 5: No title or subtitle text, skipping", file=sys.stderr)
return image return image

View File

@@ -209,7 +209,8 @@ def _run_advanced(
**config, **config,
"output": output_path, "output": output_path,
"video": video_path, "video": video_path,
"title": title_text, # 与 Electron 一致CLI title 仅主标题;勿用步骤 04 整句覆盖 titleText
"title": config.get("titleText") or title_text,
} }
generator = AdvancedCoverGenerator(merged) generator = AdvancedCoverGenerator(merged)
result = generator.generate() result = generator.generate()

View File

@@ -79,6 +79,16 @@ def resolve_cjk_font_path(
解析可用于 PIL / ffmpeg 的中文字体文件路径。 解析可用于 PIL / ffmpeg 的中文字体文件路径。
""" """
family = _normalize_family(font_family) family = _normalize_family(font_family)
try:
from modules.font_manager import get_font_manager
ziti_path = get_font_manager().find_font(family, weight)
if ziti_path and os.path.isfile(ziti_path):
return str(Path(ziti_path).resolve())
except Exception as e:
print(f"[chinese_font] font_manager lookup skipped: {e}", file=sys.stderr)
candidates = _candidate_filenames(family, weight) candidates = _candidate_filenames(family, weight)
scripts = _scripts_dir() scripts = _scripts_dir()

View File

@@ -42,10 +42,15 @@ class FontManager:
self.bundled_fonts_dir = Path("fonts/bundled") self.bundled_fonts_dir = Path("fonts/bundled")
self.fonts_metadata_file = self.bundled_fonts_dir / "fonts_metadata.json" self.fonts_metadata_file = self.bundled_fonts_dir / "fonts_metadata.json"
# 🔧 修复ziti字体路径支持ASAR打包环境 # ziti 目录环境变量优先aiclient 可指向 Electron 同款 fonts/ziti
# 检查是否在打包环境中运行 ziti_env = os.environ.get("AICLIENT_ZITI_FONTS_DIR", "").strip()
app_root = os.environ.get('APP_ROOT', None) if ziti_env and Path(ziti_env).is_dir():
if app_root: self.ziti_fonts_dir = Path(ziti_env)
print(f"✅ [font_manager] ziti from AICLIENT_ZITI_FONTS_DIR: {self.ziti_fonts_dir}")
elif app_root := os.environ.get('APP_ROOT', None):
# 🔧 修复ziti字体路径支持ASAR打包环境
# 检查是否在打包环境中运行
app_root = app_root
ziti_path_bundle = Path(app_root) / "resources-bundles" / "ziti" ziti_path_bundle = Path(app_root) / "resources-bundles" / "ziti"
if ziti_path_bundle.exists(): if ziti_path_bundle.exists():
self.ziti_fonts_dir = ziti_path_bundle self.ziti_fonts_dir = ziti_path_bundle
@@ -360,6 +365,14 @@ class FontManager:
'平方张亚玲黑方体': '平方张亚玲黑方体', '平方张亚玲黑方体': '平方张亚玲黑方体',
'胡晓波骚包体': '胡晓波骚包体2.0', '胡晓波骚包体': '胡晓波骚包体2.0',
'胡晓波骚包体2.0': '胡晓波骚包体2.0', '胡晓波骚包体2.0': '胡晓波骚包体2.0',
'USMCCyuanjiantecu': 'USMCCyuanjiantecu',
'庞门正道标题体免费版': '庞门正道标题体免费版',
'方正粗黑宋简体': '方正粗黑宋简体',
'千图厚黑体': '千图厚黑体',
'杨任东竹石体': '杨任东竹石体',
'泼墨体': '泼墨体',
'1.程荣光刻楷': '1.程荣光刻楷',
'斗鱼追光体2.0': '斗鱼追光体2.0',
} }
# 标准化字体名称(移除空格、统一大小写) # 标准化字体名称(移除空格、统一大小写)