Skip to content

fix: 修复视频叠加层中文字体在 macOS/Linux 上无法加载的问题 - #13

Open
LoicHmh wants to merge 1 commit into
yo-WASSUP:mainfrom
LoicHmh:fix/macos-chinese-font
Open

fix: 修复视频叠加层中文字体在 macOS/Linux 上无法加载的问题#13
LoicHmh wants to merge 1 commit into
yo-WASSUP:mainfrom
LoicHmh:fix/macos-chinese-font

Conversation

@LoicHmh

@LoicHmh LoicHmh commented Jul 31, 2026

Copy link
Copy Markdown

Summary

  • StatsVisualizer._find_chinese_font 之前只硬编码了 Windows 字体路径(C:/Windows/Fonts/...),在 macOS/Linux 上永远找不到,导致中文统计文字(速度/距离/回合数等标签)在视频叠加层里被 cv2.putText 渲染成 ?????
  • 改为优先使用项目自带的 simhei.ttf(跨平台通用,写法和 player_positions_zh.py 里的字体加载逻辑保持一致),再按 platform.system() 检测结果追加对应系统的字体路径作为兜底(Windows/macOS/Linux)

Test plan

  • 在 macOS (Apple Silicon) 上用 3 秒短片跑通 main.py,确认标注视频里中文统计文字正常显示,不再是问号
  • 图形叠加层(球场线/骨架/球轨迹/ROI框)不受影响

🤖 Generated with Claude Code

https://claude.ai/code/session_01ThBPLRKmwxo3JTSSnk7zw3

StatsVisualizer._find_chinese_font 之前只硬编码了 Windows 字体路径,
在 macOS/Linux 上找不到字体会 fallback 到 cv2.putText,导致中文统计
文字显示为问号。改为优先使用项目自带的 simhei.ttf(跨平台可用,
与 player_positions_zh.py 的做法一致),并按 platform.system() 检测结果
追加对应系统的字体路径作为兜底。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ThBPLRKmwxo3JTSSnk7zw3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants