Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show what custom font is used #4024

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Remove}" Appearance="Danger" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding DeleteCustomFontVisibility, Mode=OneWay}" />
</StackPanel>
</controls:OptionControl>
</StackPanel>
Expand Down
19 changes: 18 additions & 1 deletion Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

using CommunityToolkit.Mvvm.Input;

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

namespace Bloxstrap.UI.ViewModels.Settings
{
Expand Down Expand Up @@ -52,9 +54,12 @@ private void ManageCustomFont()

TextFontTask.NewState = dialog.FileName;
}


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

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

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

public System.Windows.Media.FontFamily DeleteCustomFontFontFamily => new System.Windows.Media.FontFamily($"{TextFontTask.NewState}#{CustomFontName}");

public string CustomFontName
{
get
{
var families = Fonts.GetFontFamilies(TextFontTask.NewState);
var first = families.ElementAt(0);
return first.ToString().Split("#").ElementAt(first.ToString().Split("#").Count() - 1);
}
}

public ICommand ManageCustomFontCommand => new RelayCommand(ManageCustomFont);

public ICommand OpenCompatSettingsCommand => new RelayCommand(OpenCompatSettings);
Expand Down
Binary file added Bloxstrap/content/fonts/CustomFont.ttf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is your own font here...?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where else should it be

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nowhere? i dont think custom fonts should be bundled with bloxstrap

Copy link
Author

@intervinn intervinn Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your question is still unclear to me as the fonts are never bundled with bloxstrap itself; custom fonts are stored within appdata created AFTER bloxstrap installation, which is how i grab it and use within ui.

There might be issues, since I'm really new to .NET

THIS is the reason i've stated that there might be issues, as i struggled to find a clear way to process a font file into wpf

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, i just noticed what file did you actually comment on, my bad

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like the file remained after editing

Binary file not shown.