Spaces:
Sleeping
Add per-team logos for team races + font-resolution diagnostics
Browse filesTwo additive changes; no other theme's behavior changes.
Team logos (#1): team-mode races resolve bar imagery via _load_team_logo
-> PROJECT_ROOT/assets/logos/{ABBREV}.png, but hf_space/assets/logos/ held
only NBA_logo.png (the league logo for the title). Add all 30 per-team
PNGs so team races (Thunder/Spurs/Celtics/...) show their team logo at the
left of each bar. lookup_team already maps the bare nicknames to these
abbrev filenames; PR #2's `COPY assets/logos/ /assets/logos/` deploys them.
Font diagnostics (#2): _load_font silently fell back to PIL's tiny default
bitmap on any failure, which looks like a wrong, too-small typeface. Add
definitive logging that distinguishes the two failure modes:
- font_custom_dir MISSING [...] -> files absent (Poppins fallback)
- FONT LOAD FAILED ... (unknown file format) -> present but unreadable
(e.g. a 0-byte/empty or LFS-pointer file) -> PIL default bitmap
This makes the Futura load status explicit in the Space build log.
https://claude.ai/code/session_01CvFzavoj9JGA95bn1UvZJN
- assets/logos/ATL.png +3 -0
- assets/logos/BKN.png +3 -0
- assets/logos/BOS.png +3 -0
- assets/logos/CHA.png +3 -0
- assets/logos/CHI.png +3 -0
- assets/logos/CLE.png +3 -0
- assets/logos/DAL.png +3 -0
- assets/logos/DEN.png +3 -0
- assets/logos/DET.png +3 -0
- assets/logos/GSW.png +3 -0
- assets/logos/HOU.png +3 -0
- assets/logos/IND.png +3 -0
- assets/logos/LAC.png +3 -0
- assets/logos/LAL.png +3 -0
- assets/logos/MEM.png +3 -0
- assets/logos/MIA.png +3 -0
- assets/logos/MIL.png +3 -0
- assets/logos/MIN.png +3 -0
- assets/logos/NOP.png +3 -0
- assets/logos/NYK.png +3 -0
- assets/logos/OKC.png +3 -0
- assets/logos/ORL.png +3 -0
- assets/logos/PHI.png +3 -0
- assets/logos/PHX.png +3 -0
- assets/logos/POR.png +3 -0
- assets/logos/SAC.png +3 -0
- assets/logos/SAS.png +3 -0
- assets/logos/TOR.png +3 -0
- assets/logos/UTA.png +3 -0
- assets/logos/WAS.png +3 -0
- bar_race/render.py +12 -1
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
Git LFS Details
|
|
@@ -260,7 +260,11 @@ def _resolve_font(family: str, weight: str) -> str:
|
|
| 260 |
def _load_font(path: str, size: int) -> ImageFont.FreeTypeFont | ImageFont.ImageFont:
|
| 261 |
try:
|
| 262 |
return ImageFont.truetype(path, size)
|
| 263 |
-
except (OSError, IOError):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
return ImageFont.load_default()
|
| 265 |
|
| 266 |
|
|
@@ -976,10 +980,17 @@ class FrameRenderer:
|
|
| 976 |
all_found = False
|
| 977 |
# If not all custom fonts found, fall back to standard resolution.
|
| 978 |
if not all_found:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 979 |
bold_path = cfg.font_bold
|
| 980 |
medium_path = cfg.font_medium
|
| 981 |
regular_path = cfg.font_regular
|
| 982 |
light_path = cfg.font_light
|
|
|
|
|
|
|
|
|
|
| 983 |
# Override with font_family if config used defaults (auto-resolved).
|
| 984 |
elif family != "sans":
|
| 985 |
bold_path = _resolve_font(family, "bold")
|
|
|
|
| 260 |
def _load_font(path: str, size: int) -> ImageFont.FreeTypeFont | ImageFont.ImageFont:
|
| 261 |
try:
|
| 262 |
return ImageFont.truetype(path, size)
|
| 263 |
+
except (OSError, IOError) as e:
|
| 264 |
+
# Definitive diagnostic: a present-but-unreadable file (e.g. a git-LFS
|
| 265 |
+
# pointer that never resolved) lands here and falls back to the tiny
|
| 266 |
+
# built-in bitmap font — which looks like a wrong, too-small typeface.
|
| 267 |
+
print(f"[render] FONT LOAD FAILED: {path!r} ({e}) -> PIL default bitmap")
|
| 268 |
return ImageFont.load_default()
|
| 269 |
|
| 270 |
|
|
|
|
| 980 |
all_found = False
|
| 981 |
# If not all custom fonts found, fall back to standard resolution.
|
| 982 |
if not all_found:
|
| 983 |
+
missing = [fn for fn in _custom_map.values()
|
| 984 |
+
if not (custom_dir / fn).is_file()]
|
| 985 |
+
print(f"[render] font_custom_dir {str(custom_dir)!r}: MISSING {missing} "
|
| 986 |
+
f"-> falling back to default fonts (Poppins/system)")
|
| 987 |
bold_path = cfg.font_bold
|
| 988 |
medium_path = cfg.font_medium
|
| 989 |
regular_path = cfg.font_regular
|
| 990 |
light_path = cfg.font_light
|
| 991 |
+
else:
|
| 992 |
+
print(f"[render] font_custom_dir {str(custom_dir)!r}: all 4 custom "
|
| 993 |
+
f"fonts present (bold={os.path.basename(bold_path)})")
|
| 994 |
# Override with font_family if config used defaults (auto-resolved).
|
| 995 |
elif family != "sans":
|
| 996 |
bold_path = _resolve_font(family, "bold")
|