fix: 修复视频叠加层中文字体在 macOS/Linux 上无法加载的问题 - #13
Open
LoicHmh wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
main.py,确认标注视频里中文统计文字正常显示,不再是问号🤖 Generated with Claude Code
https://claude.ai/code/session_01ThBPLRKmwxo3JTSSnk7zw3