Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* felixse#957 - using CanvasTextFormat instead of CanvasFontSet. this drops Monospace Fonts highlighting, while resolves a crash at least.

* Revert "highlight monospaced fonts"

This reverts commit 2d204e4.

# Conflicts resolved:
#	FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs
#	FluentTerminal.App/App.xaml
#	FluentTerminal.App/Services/SystemFontService.cs
#	FluentTerminal.Models/FontInfo.cs

* Fixes felixse#957 - Revert "highlight monospaced fonts"

This reverts commit 2d204e4.

# Conflicts resolved:
#	FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs
#	FluentTerminal.App/App.xaml
#	FluentTerminal.App/Services/SystemFontService.cs
#	FluentTerminal.Models/FontInfo.cs
  • Loading branch information
beyond-danube authored Jan 22, 2022
1 parent e258681 commit a76551a
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 66 deletions.
5 changes: 2 additions & 3 deletions FluentTerminal.App.Services/ISystemFontService.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using FluentTerminal.Models;
using System.Collections.Generic;
using System.Collections.Generic;

namespace FluentTerminal.App.Services
{
public interface ISystemFontService
{
IEnumerable<FontInfo> GetSystemFontFamilies();
IEnumerable<string> GetSystemFontFamilies();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public string WordSeparator
}
}

public IEnumerable<FontInfo> Fonts { get; }
public IEnumerable<string> Fonts { get; }

public int FontSize
{
Expand Down Expand Up @@ -258,7 +258,7 @@ public TerminalPageViewModel(ISettingsService settingsService, IDialogService di

RestoreDefaultsCommand = new AsyncRelayCommand(RestoreDefaultsAsync);

Fonts = systemFontService.GetSystemFontFamilies().OrderBy(s => s.Name);
Fonts = systemFontService.GetSystemFontFamilies().OrderBy(s => s);
Sizes = Enumerable.Range(2, 72);

_terminalOptions = _settingsService.GetTerminalOptions();
Expand Down
2 changes: 1 addition & 1 deletion FluentTerminal.App/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<converters:EnumValueToVisibiltyConverter x:Key="EnumValueToVisibiltyConverter" />
<converters:TabThemeSelectedConverter x:Key="TabThemeSelectedConverter" />
<converters:ColorResourceKeyFallbackConverter x:Key="ColorResourceKeyFallbackConverter" />
<converters:TrueToBoldConverter x:Key="TrueToBoldConverter" />

<converters:I18NConverter x:Key="I18NConverter" />
<converters:NullToCollapsedConverter x:Key="NullToCollapsedConverter" />
<converters:MenuViewModelToFlyoutMenuConverter x:Key="MenuViewModelToFlyoutMenuConverter" />
Expand Down
23 changes: 0 additions & 23 deletions FluentTerminal.App/Converters/TrueToBoldConverter.cs

This file was deleted.

1 change: 0 additions & 1 deletion FluentTerminal.App/FluentTerminal.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
<Compile Include="Converters\TerminalViewModelToViewConverter.cs" />
<Compile Include="Converters\TextMiddleEllipsisConverter.cs" />
<Compile Include="Converters\ToolTipValueToPixelConverter.cs" />
<Compile Include="Converters\TrueToBoldConverter.cs" />
<Compile Include="Converters\TrueToVisibleConverter.cs" />
<Compile Include="Adapters\MessageDialogAdapter.cs" />
<Compile Include="Dialogs\AboutDialog.xaml.cs">
Expand Down
20 changes: 3 additions & 17 deletions FluentTerminal.App/Services/SystemFontService.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
using FluentTerminal.Models;
using Microsoft.Graphics.Canvas.Text;
using Microsoft.Graphics.Canvas.Text;
using System.Collections.Generic;
using System.Linq;

namespace FluentTerminal.App.Services
{
public class SystemFontService : ISystemFontService
{
public IEnumerable<FontInfo> GetSystemFontFamilies()
public IEnumerable<string> GetSystemFontFamilies()
{
return CanvasFontSet.GetSystemFontSet().Fonts.Select(x => new FontInfo { Name = x.FamilyNames.Values.FirstOrDefault(), IsMonospaced = x.IsMonospaced }).Distinct(new FontInfoComparer());
return CanvasTextFormat.GetSystemFontFamilies();
}

private class FontInfoComparer : IEqualityComparer<FontInfo>
{
public bool Equals(FontInfo x, FontInfo y)
{
return x.Name == y.Name;
}

public int GetHashCode(FontInfo obj)
{
return obj.Name.GetHashCode();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public string WordSeparator
}
}

public IEnumerable<FontInfo> Fonts { get; }
public IEnumerable<string> Fonts { get; }

public int FontSize
{
Expand Down Expand Up @@ -258,7 +258,7 @@ public TerminalPageViewModel(ISettingsService settingsService, IDialogService di

RestoreDefaultsCommand = new AsyncRelayCommand(RestoreDefaultsAsync);

Fonts = systemFontService.GetSystemFontFamilies().OrderBy(s => s.Name);
Fonts = systemFontService.GetSystemFontFamilies().OrderBy(s => s);
Sizes = Enumerable.Range(2, 72);

_terminalOptions = _settingsService.GetTerminalOptions();
Expand Down
10 changes: 1 addition & 9 deletions FluentTerminal.App/Views/SettingsPages/TerminalSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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">
<Page.Resources>
<converters:ToolTipValueToPixelConverter x:Key="ToolTipValueToPixelConverter" />
Expand Down Expand Up @@ -47,14 +46,7 @@
Margin="{StaticResource ItemMargin}"
Header="Font family"
ItemsSource="{x:Bind ViewModel.Fonts}"
SelectedValue="{x:Bind ViewModel.FontFamily, Mode=TwoWay}"
SelectedValuePath="Name">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="models:FontInfo">
<TextBlock FontWeight="{x:Bind IsMonospaced, Converter={StaticResource TrueToBoldConverter}}" Text="{x:Bind Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
SelectedValue="{x:Bind ViewModel.FontFamily, Mode=TwoWay}" />

<ComboBox
x:Uid="FontSize"
Expand Down
8 changes: 0 additions & 8 deletions FluentTerminal.Models/FontInfo.cs

This file was deleted.

0 comments on commit a76551a

Please sign in to comment.