mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-06-23 06:40:03 -07:00
Merge f2d7271b3d
into 1f21e8ce0b
This commit is contained in:
commit
2a4f81b104
@ -26,7 +26,9 @@
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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 CustomFontFont}" Content="{Binding CustomFontName}" Appearance="Danger" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding DeleteCustomFontVisibility, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</controls:OptionControl>
|
||||
</StackPanel>
|
||||
|
@ -11,6 +11,8 @@ using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
using Bloxstrap.Models.SettingTasks;
|
||||
using Bloxstrap.AppData;
|
||||
using System.Windows.Media;
|
||||
using System.Drawing.Text;
|
||||
|
||||
namespace Bloxstrap.UI.ViewModels.Settings
|
||||
{
|
||||
@ -55,6 +57,8 @@ namespace Bloxstrap.UI.ViewModels.Settings
|
||||
|
||||
OnPropertyChanged(nameof(ChooseCustomFontVisibility));
|
||||
OnPropertyChanged(nameof(DeleteCustomFontVisibility));
|
||||
OnPropertyChanged(nameof(CustomFontFont));
|
||||
OnPropertyChanged(nameof(CustomFontName));
|
||||
}
|
||||
|
||||
public ICommand OpenModsFolderCommand => new RelayCommand(OpenModsFolder);
|
||||
@ -63,6 +67,41 @@ namespace Bloxstrap.UI.ViewModels.Settings
|
||||
|
||||
public Visibility DeleteCustomFontVisibility => !String.IsNullOrEmpty(TextFontTask.NewState) ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
public System.Windows.Media.FontFamily CustomFontFont
|
||||
{
|
||||
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 CustomFontName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TextFontTask.NewState == String.Empty)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
var fontFamily = CustomFontFont;
|
||||
return fontFamily.FamilyNames.Values.First();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand ManageCustomFontCommand => new RelayCommand(ManageCustomFont);
|
||||
|
||||
public ICommand OpenCompatSettingsCommand => new RelayCommand(OpenCompatSettings);
|
||||
|
Loading…
Reference in New Issue
Block a user