mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-30 01:34:08 +00:00
Simplify font retrieval in GetFonts method
Refactored GetFonts method to simplify font retrieval for all platforms.
This commit is contained in:
parent
4ae5c021fd
commit
79aa3fc27b
1 changed files with 9 additions and 20 deletions
|
|
@ -161,30 +161,19 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
|||
|
||||
private async Task<List<string>> GetFonts()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var lstFonts = new List<string>();
|
||||
try
|
||||
{
|
||||
if (Utils.IsWindows())
|
||||
{
|
||||
return lstFonts;
|
||||
}
|
||||
else if (Utils.IsNonWindows())
|
||||
{
|
||||
var result = await Utils.GetLinuxFontFamily("zh");
|
||||
if (result.IsNullOrEmpty())
|
||||
{
|
||||
return lstFonts;
|
||||
}
|
||||
|
||||
var lst = result.Split(Environment.NewLine)
|
||||
var lst = Avalonia.Media.FontManager.Current.SystemFonts
|
||||
.Select(t => t.Name)
|
||||
.Where(t => t.IsNotEmpty())
|
||||
.ToList()
|
||||
.Select(t => t.Split(",").FirstOrDefault() ?? "")
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.OrderBy(t => t)
|
||||
.ToList();
|
||||
return lst;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog("GetFonts", ex);
|
||||
|
|
|
|||
Loading…
Reference in a new issue