Files
LlamaCasty/ytLive.Tests/BundledFontsTests.cs
T
gramps ffdf3b6fc9 design: wire the sans family into the window; fonts ship as explicit Resource items
The bundled faces were packaged but unused — no style referenced FontFamily.Sans, so the app
still rendered Segoe UI. MainWindow now sets FontFamily from the token, which cascades to every
child (dialogs follow in the sweep).

Font packaging: six explicit <Resource> items instead of the Assets\Fonts\*.ttf glob, so the
guard can name exactly what must ship.

Investigation worth recording: a runtime assertion that the families resolve from
pack://application:,,,/ would have needed an Application instance inside the test host, and
without one WPF resolves the pack authority against the test host — every probe failed,
including the app icon that demonstrably works. The resources ARE embedded (the lowercase
`assets/fonts/inter-regular.ttf` entry is present in ytLive.g.resources); the assertion was
removed rather than faked, and the real confirmation is a launch, which is a visual check.

Guard remains structural: files are real binaries, each is a Resource in the csproj, the theme
uses pack URIs, notices + both OFL texts are present, and no third family sneaks in.
2026-10-30 07:53:37 -07:00

69 lines
2.9 KiB
C#

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Media;
using Xunit;
namespace ytLive.Tests;
/// <summary>The DESIGN.md type standard names Inter and JetBrains Mono, and the creator ruled
/// (2026-10-30) that they ship with the app rather than depending on what the machine happens to
/// have installed. That makes them third-party assets with obligations, so this guard covers the
/// whole chain: the files are present and unmodified, the project ships them as resources, the
/// theme resolves them from the pack folder, and the OFL notice + license text travel with them.
///
/// <para>A missing font would otherwise fail silently — WPF falls back to a system face and the
/// design standard quietly stops being true.</para></summary>
public class BundledFontsTests
{
private static readonly string[] Files =
{
"Inter-Regular.ttf", "Inter-Medium.ttf", "Inter-SemiBold.ttf", "Inter-Bold.ttf",
"JetBrainsMono-Medium.ttf", "JetBrainsMono-SemiBold.ttf",
};
[Fact]
public void The_standard_typefaces_ship_bundled_with_their_OFL_notice()
{
// 1. The files are there and are real font binaries, not placeholders.
foreach (var name in Files)
{
var path = SourceAssert.RepoPath("Assets", "Fonts", name);
Assert.True(new FileInfo(path).Length > 50_000, $"{name} looks like a placeholder");
}
// 2. The project packages each one as a WPF resource (an explicit item, not a guess).
var csproj = SourceAssert.Text("ytLive.csproj");
foreach (var name in Files)
Assert.Contains($@"Assets\Fonts\{name}", csproj);
// 3. The theme resolves each family from the pack folder — a bare family name would
// only work if the user happened to have the font installed.
var tokens = SourceAssert.Text("Themes", "Tokens.xaml");
Assert.Contains("/Assets/Fonts/#Inter", tokens);
Assert.Contains("/Assets/Fonts/#JetBrains Mono", tokens);
// 4. The OFL obligations: notice in THIRD-PARTY-NOTICES.txt, license text beside the files.
var notices = SourceAssert.Text("THIRD-PARTY-NOTICES.txt");
Assert.Contains("Inter", notices);
Assert.Contains("JetBrains Mono", notices);
Assert.Contains("SIL Open Font License 1.1", notices);
foreach (var ofl in new[] { "OFL-Inter.txt", "OFL-JetBrainsMono.txt" })
{
var text = SourceAssert.Text("Assets", "Fonts", ofl);
Assert.Contains("SIL OPEN FONT LICENSE", text);
}
// 5. No other font family sneaks in through the token sheet.
var families = SourceAssert.Text("Themes", "Tokens.xaml")
.Split('\n')
.Where(l => l.Contains("FontFamily x:Key=", System.StringComparison.Ordinal))
.ToList();
Assert.Equal(2, families.Count);
}
}