Skip to content
Open
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
4 changes: 3 additions & 1 deletion Bloxstrap/Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ static class Paths

public static string Application { get; private set; } = "";

public static string CustomFont => Path.Combine(Modifications, "content\\fonts\\CustomFont.ttf");
public static string Fonts => Path.Combine(Modifications, "content\\fonts");
public static string CustomFont => Path.Combine(Fonts, "CustomFont.ttf");


public static bool Initialized => !String.IsNullOrEmpty(Base);

Expand Down
2 changes: 1 addition & 1 deletion Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
Description="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Description}">
<StackPanel>
<ui:Button Icon="DocumentAdd16" Content="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Choose}" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding ChooseCustomFontVisibility, Mode=OneWay}" />
<ui:Button Icon="Delete16" Content="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Remove}" Appearance="Danger" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding DeleteCustomFontVisibility, Mode=OneWay}" />
<ui:Button Icon="Delete16" FontFamily="{Binding DeleteCustomFontFontFamily}" Content="{Binding DeleteCustomFontFontName}" Appearance="Danger" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding DeleteCustomFontVisibility, Mode=OneWay}" />
</StackPanel>
</controls:OptionControl>
</StackPanel>
Expand Down
39 changes: 39 additions & 0 deletions Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

using Bloxstrap.Models.SettingTasks;
using Bloxstrap.AppData;
using System.Windows.Media;
using System.Drawing.Text;

namespace Bloxstrap.UI.ViewModels.Settings
{
Expand Down Expand Up @@ -55,6 +57,8 @@ private void ManageCustomFont()

OnPropertyChanged(nameof(ChooseCustomFontVisibility));
OnPropertyChanged(nameof(DeleteCustomFontVisibility));
OnPropertyChanged(nameof(DeleteCustomFontFontFamily));
OnPropertyChanged(nameof(DeleteCustomFontFontName));
}

public ICommand OpenModsFolderCommand => new RelayCommand(OpenModsFolder);
Expand All @@ -63,6 +67,41 @@ private void ManageCustomFont()

public Visibility DeleteCustomFontVisibility => !String.IsNullOrEmpty(TextFontTask.NewState) ? Visibility.Visible : Visibility.Collapsed;

public System.Windows.Media.FontFamily DeleteCustomFontFontFamily
{
get
{
using (PrivateFontCollection collection = new PrivateFontCollection())
{
Uri uri;
if (TextFontTask.NewState == String.Empty)
{
uri = new Uri("pack://application:,,,/Resources/Fonts/Rubik-VariableFont_wght.ttf");
} else
{
uri = new Uri(TextFontTask.NewState, UriKind.Absolute);
}

var fontFamilies = Fonts.GetFontFamilies(uri);
return fontFamilies.First();
}
}
}

public string DeleteCustomFontFontName
{
get
{
if (TextFontTask.NewState == String.Empty)
{
return String.Empty;
}

var fontFamily = DeleteCustomFontFontFamily;
return String.Join(" ", fontFamily.FamilyNames.Values);
}
}

public ICommand ManageCustomFontCommand => new RelayCommand(ManageCustomFont);

public ICommand OpenCompatSettingsCommand => new RelayCommand(OpenCompatSettings);
Expand Down