diff --git a/scripts/cover/advanced_cover_generator.py b/scripts/cover/advanced_cover_generator.py index 69d65ad..8aaaf21 100644 --- a/scripts/cover/advanced_cover_generator.py +++ b/scripts/cover/advanced_cover_generator.py @@ -657,6 +657,19 @@ class AdvancedCoverGenerator: title_text = self.config.get('title', self.template.get('titleText', '')) 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: print("Step 5: No title or subtitle text, skipping", file=sys.stderr) return image diff --git a/scripts/cover/cover_generate.py b/scripts/cover/cover_generate.py index 157ffe4..c9512db 100644 --- a/scripts/cover/cover_generate.py +++ b/scripts/cover/cover_generate.py @@ -209,7 +209,8 @@ def _run_advanced( **config, "output": output_path, "video": video_path, - "title": title_text, + # 与 Electron 一致:CLI title 仅主标题;勿用步骤 04 整句覆盖 titleText + "title": config.get("titleText") or title_text, } generator = AdvancedCoverGenerator(merged) result = generator.generate() diff --git a/scripts/cover/modules/chinese_font.py b/scripts/cover/modules/chinese_font.py index 6ba7b26..d8bc76e 100644 --- a/scripts/cover/modules/chinese_font.py +++ b/scripts/cover/modules/chinese_font.py @@ -79,6 +79,16 @@ def resolve_cjk_font_path( 解析可用于 PIL / ffmpeg 的中文字体文件路径。 """ 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) scripts = _scripts_dir() diff --git a/scripts/cover/modules/font_manager.py b/scripts/cover/modules/font_manager.py index cca87e8..19c8e01 100644 --- a/scripts/cover/modules/font_manager.py +++ b/scripts/cover/modules/font_manager.py @@ -42,10 +42,15 @@ class FontManager: self.bundled_fonts_dir = Path("fonts/bundled") self.fonts_metadata_file = self.bundled_fonts_dir / "fonts_metadata.json" - # 🔧 修复ziti字体路径:支持ASAR打包环境 - # 检查是否在打包环境中运行 - app_root = os.environ.get('APP_ROOT', None) - if app_root: + # ziti 目录:环境变量优先(aiclient 可指向 Electron 同款 fonts/ziti) + ziti_env = os.environ.get("AICLIENT_ZITI_FONTS_DIR", "").strip() + if ziti_env and Path(ziti_env).is_dir(): + 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" if ziti_path_bundle.exists(): self.ziti_fonts_dir = ziti_path_bundle @@ -360,6 +365,14 @@ class FontManager: '平方张亚玲黑方体': '平方张亚玲黑方体', '胡晓波骚包体': '胡晓波骚包体2.0', '胡晓波骚包体2.0': '胡晓波骚包体2.0', + 'USMCCyuanjiantecu': 'USMCCyuanjiantecu', + '庞门正道标题体免费版': '庞门正道标题体免费版', + '方正粗黑宋简体': '方正粗黑宋简体', + '千图厚黑体': '千图厚黑体', + '杨任东竹石体': '杨任东竹石体', + '泼墨体': '泼墨体', + '1.程荣光刻楷': '1.程荣光刻楷', + '斗鱼追光体2.0': '斗鱼追光体2.0', } # 标准化字体名称(移除空格、统一大小写)