1111
1212using Bloxstrap . Models . SettingTasks ;
1313using Bloxstrap . AppData ;
14+ using System . Windows . Media ;
15+ using System . Drawing . Text ;
1416
1517namespace Bloxstrap . UI . ViewModels . Settings
1618{
@@ -55,6 +57,8 @@ private void ManageCustomFont()
5557
5658 OnPropertyChanged ( nameof ( ChooseCustomFontVisibility ) ) ;
5759 OnPropertyChanged ( nameof ( DeleteCustomFontVisibility ) ) ;
60+ OnPropertyChanged ( nameof ( CustomFontFont ) ) ;
61+ OnPropertyChanged ( nameof ( CustomFontName ) ) ;
5862 }
5963
6064 public ICommand OpenModsFolderCommand => new RelayCommand ( OpenModsFolder ) ;
@@ -63,6 +67,40 @@ private void ManageCustomFont()
6367
6468 public Visibility DeleteCustomFontVisibility => ! String . IsNullOrEmpty ( TextFontTask . NewState ) ? Visibility . Visible : Visibility . Collapsed ;
6569
70+ public System . Windows . Media . FontFamily CustomFontFont {
71+ get
72+ {
73+ using ( PrivateFontCollection collection = new PrivateFontCollection ( ) )
74+ {
75+ Uri uri ;
76+ if ( TextFontTask . NewState == String . Empty )
77+ {
78+ uri = new Uri ( "pack://application:,,,/Resources/Fonts/Rubik-VariableFont_wght.ttf" ) ;
79+ } else
80+ {
81+ uri = new Uri ( TextFontTask . NewState , UriKind . Absolute ) ;
82+ }
83+
84+ var fontFamilies = Fonts . GetFontFamilies ( uri ) ;
85+ return fontFamilies . First ( ) ;
86+ }
87+ }
88+ }
89+
90+ public string CustomFontName
91+ {
92+ get
93+ {
94+ if ( TextFontTask . NewState == String . Empty )
95+ {
96+ return String . Empty ;
97+ }
98+
99+ var fontFamily = CustomFontFont ;
100+ return fontFamily . FamilyNames . Values . First ( ) ;
101+ }
102+ }
103+
66104 public ICommand ManageCustomFontCommand => new RelayCommand ( ManageCustomFont ) ;
67105
68106 public ICommand OpenCompatSettingsCommand => new RelayCommand ( OpenCompatSettings ) ;
0 commit comments