#!/usr/bin/env python3 """ 复制字体文件到 public/fonts 目录 """ import os import shutil from pathlib import Path def copy_fonts(source_dir='font', target_dir='frontend/public/fonts'): """复制字体文件""" source_path = Path(source_dir) target_path = Path(target_dir) if not source_path.exists(): print(f"源目录不存在: {source_dir}") return # 清空目标目录 if target_path.exists(): shutil.rmtree(target_path) # 创建目标目录 target_path.mkdir(parents=True, exist_ok=True) copied_count = 0 # 遍历所有子目录 for category_dir in sorted(source_path.iterdir()): if not category_dir.is_dir(): continue category_name = category_dir.name category_target = target_path / category_name category_target.mkdir(exist_ok=True) # 复制字体文件 for font_file in sorted(category_dir.iterdir()): if font_file.suffix.lower() not in ['.ttf', '.otf']: continue target_file = category_target / font_file.name shutil.copy2(font_file, target_file) copied_count += 1 print(f"复制: {font_file} -> {target_file}") print(f"\n总共复制了 {copied_count} 个字体文件到 {target_dir}") if __name__ == '__main__': copy_fonts()