Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
更改字体列表的读取方式以避免崩溃 (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonWei512 authored Nov 2, 2021
1 parent b8a46ac commit c606355
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions src/Utilities/Toolkit/Toolkit.Uwp/FontToolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,13 @@ public class FontToolkit : IFontToolkit
/// <inheritdoc/>
public List<string> GetSystemFontList()
{
var defaultLan = "en-us";
try
{
var fonts = CanvasFontSet.GetSystemFontSet();
var result = new List<string>();
foreach (var font in fonts.Fonts)
var localeList = new List<string>
{
font.FamilyNames.TryGetValue(defaultLan, out var fontName);
if (string.IsNullOrEmpty(fontName) && font.FamilyNames.Count > 0)
{
fontName = font.FamilyNames.First().Value;
}

if (!string.IsNullOrEmpty(fontName) && !result.Contains(fontName))
{
result.Add(fontName);
}
}

return result;
"zh-cn",
};
return CanvasTextFormat.GetSystemFontFamilies(localeList).OrderBy(x => x).ToList();
}
catch (System.Exception)
{
Expand Down

0 comments on commit c606355

Please sign in to comment.