From 3c3b9147c442dbc3310953bc09fe15100cd00279 Mon Sep 17 00:00:00 2001 From: KnifeLemon Date: Thu, 12 Nov 2026 21:16:24 +0900 Subject: [PATCH] fix(fonts): Get fonts opens Microsoft's pages for Aptos and DengXian Neither is on Google Fonts, so the search found nothing. Aptos (Office's default since 2023) goes to Microsoft's download for local installation, DengXian to its Microsoft typography page. Co-Authored-By: Claude Opus 5.5 --- src/Filee.App/Services/FontSources.cs | 12 ++++++++++ tests/Filee.App.Tests/FontSourcesTests.cs | 27 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/Filee.App.Tests/FontSourcesTests.cs diff --git a/src/Filee.App/Services/FontSources.cs b/src/Filee.App/Services/FontSources.cs index 276f1f58f..918cd50a6 100644 --- a/src/Filee.App/Services/FontSources.cs +++ b/src/Filee.App/Services/FontSources.cs @@ -15,6 +15,10 @@ public static class FontSources ["Cambria"] = "cambria", ["Cambria Math"] = "cambria-math", ["Courier New"] = "courier-new", + ["DengXian"] = "dengxian", + ["DengXian Light"] = "dengxian", + ["等线"] = "dengxian", + ["等线 Light"] = "dengxian", ["Tahoma"] = "tahoma", ["Times New Roman"] = "times-new-roman", }; @@ -33,7 +37,15 @@ public static class FontSources "Wingdings", "Wingdings 2", "Wingdings 3", "Webdings", "Symbol", "OpenSymbol", }; + // Office's default font since 2023. Office fetches it from its cloud font service for itself, so other programs don't + // see it until it is installed from this download (Windows and macOS). + private const string AptosDownload = "https://www.microsoft.com/en-us/download/details.aspx?id=106087"; + + private static bool IsAptos(string family) => family.Equals("Aptos", StringComparison.OrdinalIgnoreCase) + || family.StartsWith("Aptos ", StringComparison.OrdinalIgnoreCase); + public static Uri? Url(string family) => NoPublicFontPage.Contains(family) ? null + : IsAptos(family) ? new Uri(AptosDownload) : Microsoft.TryGetValue(family, out var page) ? new Uri("https://learn.microsoft.com/en-us/typography/font-list/" + page) : OtherOfficial.TryGetValue(family, out var official) ? new Uri(official) diff --git a/tests/Filee.App.Tests/FontSourcesTests.cs b/tests/Filee.App.Tests/FontSourcesTests.cs new file mode 100644 index 000000000..b3876756e --- /dev/null +++ b/tests/Filee.App.Tests/FontSourcesTests.cs @@ -0,0 +1,27 @@ +// Get fonts must lead to the font's own source: Aptos and DengXian aren't on Google Fonts (#1422, #1423). + +using Filee.App.Services; + +namespace Filee.App.Tests; + +public class FontSourcesTests +{ + [Theory] + [InlineData("Aptos")] + [InlineData("Aptos Display")] + [InlineData("Aptos Narrow")] + [InlineData("aptos serif")] + public void Aptos_goes_to_microsofts_download(string family) => + Assert.Equal("https://www.microsoft.com/en-us/download/details.aspx?id=106087", FontSources.Url(family)!.ToString()); + + [Theory] + [InlineData("DengXian")] + [InlineData("DengXian Light")] + [InlineData("等线")] + public void DengXian_goes_to_its_microsoft_typography_page(string family) => + Assert.Equal("https://learn.microsoft.com/en-us/typography/font-list/dengxian", FontSources.Url(family)!.ToString()); + + [Fact] + public void A_family_that_only_starts_with_aptos_letters_is_still_searched() => + Assert.Equal("https://fonts.google.com/?query=Aptosa", FontSources.Url("Aptosa")!.ToString()); +}