CustomFontMapper crashes on a null font_family instead of using the default font #572

Open
opened 2026-07-22 23:40:58 +02:00 by timothy · 0 comments
Owner

CustomFontMapper.TypefaceFromStyle (ErsatzTV.Infrastructure/Streaming/Graphics/Fonts/CustomFontMapper.cs:39) does _customFonts.TryGetValue(style.FontFamily, ...); when a text graphics element style omits font_family, style.FontFamily is null and TryGetValue(null, ...) throws — crashing text-element init before the graceful base.TypefaceFromStyle(...) default-font fallback a few lines below.

Surfaced by #570 (the seeded On Now/Next element crashed on a null font_family). #570 worked around it by giving every seeded style an explicit font_family, but any user-authored text element without a font_family hits the same crash instead of falling back to the default font.

Fix: treat a null/empty font_family as "use default" — e.g. guard the TryGetValue on a non-empty family, or default qualifiedName before the lookup, so it reaches base.TypefaceFromStyle.

`CustomFontMapper.TypefaceFromStyle` (`ErsatzTV.Infrastructure/Streaming/Graphics/Fonts/CustomFontMapper.cs:39`) does `_customFonts.TryGetValue(style.FontFamily, ...)`; when a text graphics element style omits `font_family`, `style.FontFamily` is null and `TryGetValue(null, ...)` throws — crashing text-element init **before** the graceful `base.TypefaceFromStyle(...)` default-font fallback a few lines below. Surfaced by #570 (the seeded On Now/Next element crashed on a null font_family). #570 worked around it by giving every seeded style an explicit `font_family`, but any user-authored text element without a font_family hits the same crash instead of falling back to the default font. Fix: treat a null/empty `font_family` as "use default" — e.g. guard the `TryGetValue` on a non-empty family, or default `qualifiedName` before the lookup, so it reaches `base.TypefaceFromStyle`.
timothy added the priority: low label 2026-07-22 23:40:58 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#572