Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed PCL.Launcher/Assets/Fonts/Font.ttf
Binary file not shown.
29 changes: 2 additions & 27 deletions PCL.Launcher/UI/Controls/Feedback/LaunchFonts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
namespace PCL.UI.Controls;

/// <summary>
/// 启动器字体链:内置的 <c>PCL English</c> 负责拉丁字形,其余字体按当前 UI 语言回退到系统字体。
/// 用户指定字体时插到首位,由 <see cref="InstallGlobalFont" /> 写入应用级资源。
/// </summary>
internal static class LaunchFonts
{
public const string ApplicationFontKey = "LaunchFontFamily";
private const string EmbeddedFontFamily = "PCL English";
internal const string EmbeddedFontUri = "avares://PCL.Launcher/Assets/Fonts#PCL English";

private static readonly Lock PreviewFallbackLock = new();
private static string? _previewFallbackChain;
Expand Down Expand Up @@ -93,15 +90,7 @@ private static string GetPreviewFallbackChain()
return _previewFallbackChain;

var families = GetDefaultFamilies(profile)
.Select(family => string.Equals(
family,
EmbeddedFontFamily,
StringComparison.OrdinalIgnoreCase)
? EmbeddedFontUri
: family)
.Where(family =>
family.StartsWith("avares://", StringComparison.OrdinalIgnoreCase)
|| _IsFontAvailable(family))
.Where(_IsFontAvailable)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();

Expand Down Expand Up @@ -187,15 +176,7 @@ private static FontFamily Parse(IEnumerable<string> families, FontFamily fallbac
{
var names = families
.Where(family => !string.IsNullOrWhiteSpace(family))
.Where(family =>
string.Equals(family, EmbeddedFontFamily, StringComparison.OrdinalIgnoreCase)
|| _IsFontAvailable(family))
.Select(family => string.Equals(
family,
EmbeddedFontFamily,
StringComparison.OrdinalIgnoreCase)
? EmbeddedFontUri
: family)
.Where(_IsFontAvailable)
.Distinct(StringComparer.OrdinalIgnoreCase);

try
Expand All @@ -214,7 +195,6 @@ private static IReadOnlyList<string> GetDefaultFamilies(LocalizationFontProfile
{
LocalizationFontProfile.English =>
[
EmbeddedFontFamily,
"Microsoft YaHei UI",
"Segoe UI",
"Helvetica Neue",
Expand All @@ -224,7 +204,6 @@ private static IReadOnlyList<string> GetDefaultFamilies(LocalizationFontProfile

LocalizationFontProfile.SimplifiedChinese =>
[
EmbeddedFontFamily,
"Microsoft YaHei UI",
"Segoe UI",
"PingFang SC",
Expand All @@ -238,7 +217,6 @@ private static IReadOnlyList<string> GetDefaultFamilies(LocalizationFontProfile

LocalizationFontProfile.TraditionalChinese =>
[
EmbeddedFontFamily,
"Microsoft JhengHei UI",
"Microsoft YaHei UI",
"Segoe UI",
Expand All @@ -250,7 +228,6 @@ private static IReadOnlyList<string> GetDefaultFamilies(LocalizationFontProfile

LocalizationFontProfile.Japanese =>
[
EmbeddedFontFamily,
"Yu Gothic UI",
"Microsoft YaHei UI",
"Segoe UI",
Expand All @@ -262,7 +239,6 @@ private static IReadOnlyList<string> GetDefaultFamilies(LocalizationFontProfile

LocalizationFontProfile.Korean =>
[
EmbeddedFontFamily,
"Malgun Gothic",
"Microsoft YaHei UI",
"Segoe UI",
Expand All @@ -273,7 +249,6 @@ private static IReadOnlyList<string> GetDefaultFamilies(LocalizationFontProfile

_ =>
[
EmbeddedFontFamily,
"Segoe UI",
"Microsoft YaHei UI",
"PingFang SC",
Expand Down
12 changes: 0 additions & 12 deletions PCL.Launcher/UI/Controls/Feedback/PlatformFontProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ internal static class PlatformFontProvider
public static IPlatformFontProvider Current => PlatformRuntime.Current.Kind switch
{
PlatformKind.Windows => new WindowsFontProvider(),
PlatformKind.Linux => new LinuxFontProvider(),
PlatformKind.MacOs => new MacOsFontProvider(),
_ => throw new ArgumentOutOfRangeException()
};
}
Expand All @@ -18,13 +16,3 @@ internal sealed class WindowsFontProvider : IPlatformFontProvider
{
public FontFamily CreateBannerFont() => LaunchFonts.Build("Bahnschrift");
}

internal sealed class LinuxFontProvider : IPlatformFontProvider
{
public FontFamily CreateBannerFont() => new(LaunchFonts.EmbeddedFontUri);
}

internal sealed class MacOsFontProvider : IPlatformFontProvider
{
public FontFamily CreateBannerFont() => new(LaunchFonts.EmbeddedFontUri);
}
Loading