diff --git a/FluentTerminal.App.Services/ISystemFontService.cs b/FluentTerminal.App.Services/ISystemFontService.cs index 3e7c0b5..efef46f 100644 --- a/FluentTerminal.App.Services/ISystemFontService.cs +++ b/FluentTerminal.App.Services/ISystemFontService.cs @@ -1,9 +1,10 @@ -using System.Collections.Generic; +using FluentTerminal.Models; +using System.Collections.Generic; namespace FluentTerminal.App.Services { public interface ISystemFontService { - IEnumerable GetSystemFontFamilies(); + IEnumerable GetSystemFontFamilies(); } } \ No newline at end of file diff --git a/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs b/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs index c40b72a..a880cc7 100644 --- a/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs +++ b/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs @@ -150,7 +150,7 @@ namespace FluentTerminal.App.ViewModels.Settings } } - public IEnumerable Fonts { get; } + public IEnumerable Fonts { get; } public int FontSize { @@ -234,7 +234,7 @@ namespace FluentTerminal.App.ViewModels.Settings RestoreDefaultsCommand = new RelayCommand(async () => await RestoreDefaults().ConfigureAwait(false)); - Fonts = systemFontService.GetSystemFontFamilies().OrderBy(s => s); + Fonts = systemFontService.GetSystemFontFamilies().OrderBy(s => s.Name); Sizes = Enumerable.Range(1, 72); _terminalOptions = _settingsService.GetTerminalOptions(); diff --git a/FluentTerminal.App/App.xaml b/FluentTerminal.App/App.xaml index c3fe933..45e8bf1 100644 --- a/FluentTerminal.App/App.xaml +++ b/FluentTerminal.App/App.xaml @@ -38,6 +38,7 @@ + \ No newline at end of file diff --git a/FluentTerminal.App/Converters/TrueToBoldConverter.cs b/FluentTerminal.App/Converters/TrueToBoldConverter.cs new file mode 100644 index 0000000..64b79fa --- /dev/null +++ b/FluentTerminal.App/Converters/TrueToBoldConverter.cs @@ -0,0 +1,23 @@ +using System; +using Windows.UI.Text; +using Windows.UI.Xaml.Data; + +namespace FluentTerminal.App.Converters +{ + public class TrueToBoldConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value is bool bold) + { + return bold ? FontWeights.Bold : FontWeights.Normal; + } + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } +} diff --git a/FluentTerminal.App/FluentTerminal.App.csproj b/FluentTerminal.App/FluentTerminal.App.csproj index 01f89e5..7d7724c 100644 --- a/FluentTerminal.App/FluentTerminal.App.csproj +++ b/FluentTerminal.App/FluentTerminal.App.csproj @@ -124,6 +124,7 @@ + diff --git a/FluentTerminal.App/Services/SystemFontService.cs b/FluentTerminal.App/Services/SystemFontService.cs index 9ccc0ff..b109b4b 100644 --- a/FluentTerminal.App/Services/SystemFontService.cs +++ b/FluentTerminal.App/Services/SystemFontService.cs @@ -1,13 +1,28 @@ -using Microsoft.Graphics.Canvas.Text; +using FluentTerminal.Models; +using Microsoft.Graphics.Canvas.Text; using System.Collections.Generic; +using System.Linq; namespace FluentTerminal.App.Services { public class SystemFontService : ISystemFontService { - public IEnumerable GetSystemFontFamilies() + public IEnumerable GetSystemFontFamilies() { - return CanvasTextFormat.GetSystemFontFamilies(); + return CanvasFontSet.GetSystemFontSet().Fonts.Select(x => new FontInfo { Name = x.FamilyNames.Values.FirstOrDefault(), IsMonospaced = x.IsMonospaced }).Distinct(new FontInfoComparer()); + } + + private class FontInfoComparer : IEqualityComparer + { + public bool Equals(FontInfo x, FontInfo y) + { + return x.Name == y.Name; + } + + public int GetHashCode(FontInfo obj) + { + return obj.Name.GetHashCode(); + } } } } \ No newline at end of file diff --git a/FluentTerminal.App/Views/SettingsPages/TerminalSettings.xaml b/FluentTerminal.App/Views/SettingsPages/TerminalSettings.xaml index 88423c1..c4b15f0 100644 --- a/FluentTerminal.App/Views/SettingsPages/TerminalSettings.xaml +++ b/FluentTerminal.App/Views/SettingsPages/TerminalSettings.xaml @@ -5,6 +5,7 @@ xmlns:converters="using:FluentTerminal.App.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:models="using:FluentTerminal.Models" mc:Ignorable="d"> @@ -45,7 +46,14 @@ Margin="{StaticResource ItemMargin}" Header="Font family" ItemsSource="{x:Bind ViewModel.Fonts}" - SelectedValue="{x:Bind ViewModel.FontFamily, Mode=TwoWay}" /> + SelectedValue="{x:Bind ViewModel.FontFamily, Mode=TwoWay}" + SelectedValuePath="Name"> + + + + + +