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; /// 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. /// /// A missing font would otherwise fail silently — WPF falls back to a system face and the /// design standard quietly stops being true. 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); } }