From 892f4e354bd45d2168e6bd1e0f052c3cb4dc4fde Mon Sep 17 00:00:00 2001 From: Timothy Date: Wed, 22 Jul 2026 23:10:35 +0200 Subject: [PATCH] =?UTF-8?q?fix(570):=20On=20Now/Next=20overlay=20YAML=20re?= =?UTF-8?q?nders=20=E2=80=94=20font=5Ffamily=20+=20format=5Fdatetime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #74 seeded on-now-next.yml never rendered at transcode time: - format_datetime was called with 2 args; it needs 3 (DateTimeOffset, timeZoneId, format) and does the tz conversion itself, so the Scriban render threw. Drop the NEXT start-time (avoids hardcoding a timezone in a shipped default). - styles had no font_family; CustomFontMapper.TypefaceFromStyle crashes on a null family before its default-font fallback. Add font_family: Noto Sans. Verified live on ersatztv-test via frame capture. Adds a seeder test that deserializes the YAML and asserts base_style resolves + every style sets a font. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Graphics/GraphicsElementSeeder.cs | 5 +++- .../GraphicsElementSeederTests.cs | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElementSeeder.cs b/ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElementSeeder.cs index 05024749b..ea3abee80 100644 --- a/ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElementSeeder.cs +++ b/ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElementSeeder.cs @@ -25,18 +25,21 @@ public static class GraphicsElementSeeder base_style: now styles: - name: now + font_family: "Noto Sans" font_size: 30 font_weight: 700 text_color: "#FFFFFF" halo_color: "#000000" halo_width: 2 - name: sub + font_family: "Noto Sans" font_size: 22 font_weight: 400 text_color: "#DDDDDD" halo_color: "#000000" halo_width: 2 - name: next + font_family: "Noto Sans" font_size: 22 font_weight: 400 text_color: "#DDDDDD" @@ -45,7 +48,7 @@ public static class GraphicsElementSeeder text: | [now]NOW {{ Epg[0].Title }}[/now] {{ if Epg[0].SubTitle }}[sub]{{ Epg[0].SubTitle }}[/sub]{{ end }} - {{ if Epg.size > 1 }}[next]NEXT {{ Epg[1].Title }} · {{ format_datetime (convert_timezone Epg[1].Start) "h:mm tt" }}[/next]{{ end }} + {{ if (array.size Epg) > 1 }}[next]NEXT {{ Epg[1].Title }}[/next]{{ end }} """; public static async Task SeedOnNowNext(TvContext context, IFileSystem fileSystem, CancellationToken cancellationToken) diff --git a/ErsatzTV.Tests/Infrastructure/GraphicsElementSeederTests.cs b/ErsatzTV.Tests/Infrastructure/GraphicsElementSeederTests.cs index b840b2d67..fb6adb616 100644 --- a/ErsatzTV.Tests/Infrastructure/GraphicsElementSeederTests.cs +++ b/ErsatzTV.Tests/Infrastructure/GraphicsElementSeederTests.cs @@ -8,6 +8,9 @@ using ErsatzTV.Tests.Support; using Microsoft.EntityFrameworkCore; using NUnit.Framework; using Shouldly; +using YamlDotNet.Serialization; +using YamlDotNet.Serialization.NamingConventions; +using ErsatzTV.Core.Graphics; namespace ErsatzTV.Tests.Infrastructure; @@ -65,4 +68,28 @@ public class GraphicsElementSeederTests fs.File.Exists(_seededPath).ShouldBeFalse(); } + + // Guards the #570 render bugs: the seeded YAML must deserialize into a TextGraphicsElement whose + // base_style names a real style and whose every style sets a font_family — a null font_family + // crashes CustomFontMapper before its default-font fallback, so the overlay silently never renders. + [Test] + public async Task Seeded_Element_Deserializes_With_Resolvable_BaseStyle_And_Font_Families() + { + var fs = new MockFileSystem(); + await using TvContext context = _db.CreateContext(); + await GraphicsElementSeeder.SeedOnNowNext(context, fs, CancellationToken.None); + + string yaml = await fs.File.ReadAllTextAsync(_seededPath); + IDeserializer deserializer = new DeserializerBuilder() + .WithNamingConvention(CamelCaseNamingConvention.Instance) + .IgnoreUnmatchedProperties() + .Build(); + + var element = deserializer.Deserialize(yaml); + + element.ShouldNotBeNull(); + element.Styles.ShouldNotBeEmpty(); + element.Styles.Select(s => s.Name).ShouldContain(element.BaseStyle); + element.Styles.ShouldAllBe(s => !string.IsNullOrWhiteSpace(s.FontFamily)); + } } -- 2.47.3