Skip to content

Commit

Permalink
upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
hellzerg committed Jul 22, 2023
1 parent 31183c5 commit 4d1520c
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 15 deletions.
9 changes: 1 addition & 8 deletions Optimizer/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Optimizer
namespace Optimizer
{
internal static class Constants
{
Expand Down
75 changes: 74 additions & 1 deletion Optimizer/FontHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;

namespace Optimizer
{
Expand Down Expand Up @@ -28,5 +31,75 @@ internal static void LoadFont()

Poppins15 = new Font(fonts.Families[0], 13f);
}

internal static IEnumerable<string> GetAvailableFonts()
{
return new InstalledFontCollection().Families.Select(x => x.Name);
}

internal static void ChangeGlobalFont(string fontName)
{
try
{
using (RegistryKey fontsKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", true))
{
fontsKey.SetValue("Segoe UI (TrueType)", "");
fontsKey.SetValue("Segoe UI Bold (TrueType)", "");
fontsKey.SetValue("Segoe UI Bold Italic (TrueType)", "");
fontsKey.SetValue("Segoe UI Italic (TrueType)", "");
fontsKey.SetValue("Segoe UI Light (TrueType)", "");
fontsKey.SetValue("Segoe UI Semibold (TrueType)", "");
fontsKey.SetValue("Segoe UI Symbol (TrueType)", "");
}

using (RegistryKey fontSubstitutesKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", true))
{
fontSubstitutesKey.SetValue("Segoe UI", fontName);
}
}
catch (Exception ex)
{
ErrorLogger.LogError("FontHelper.ChangeGlobalFont", ex.Message, ex.StackTrace);
}
}

internal static void RestoreDefaultGlobalFont()
{
try
{
using (RegistryKey fontsKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", true))
{
fontsKey.SetValue("Segoe UI (TrueType)", "segoeui.ttf");
fontsKey.SetValue("Segoe UI Black (TrueType)", "seguibl.ttf");
fontsKey.SetValue("Segoe UI Black Italic (TrueType)", "seguibli.ttf");
fontsKey.SetValue("Segoe UI Bold (TrueType)", "segoeuib.ttf");
fontsKey.SetValue("Segoe UI Bold Italic (TrueType)", "segoeuiz.ttf");
fontsKey.SetValue("Segoe UI Emoji (TrueType)", "seguiemj.ttf");
fontsKey.SetValue("Segoe UI Historic (TrueType)", "seguihis.ttf");
fontsKey.SetValue("Segoe UI Italic (TrueType)", "segoeuii.ttf");
fontsKey.SetValue("Segoe UI Light (TrueType)", "segoeuil.ttf");
fontsKey.SetValue("Segoe UI Light Italic (TrueType)", "seguili.ttf");
fontsKey.SetValue("Segoe UI Semibold (TrueType)", "seguisb.ttf");
fontsKey.SetValue("Segoe UI Semibold Italic (TrueType)", "seguisbi.ttf");
fontsKey.SetValue("Segoe UI Semilight (TrueType)", "segoeuisl.ttf");
fontsKey.SetValue("Segoe UI Semilight Italic (TrueType)", "seguisli.ttf");
fontsKey.SetValue("Segoe UI Symbol (TrueType)", "seguisym.ttf");
fontsKey.SetValue("Segoe MDL2 Assets (TrueType)", "segmdl2.ttf");
fontsKey.SetValue("Segoe Print (TrueType)", "segoepr.ttf");
fontsKey.SetValue("Segoe Print Bold (TrueType)", "segoeprb.ttf");
fontsKey.SetValue("Segoe Script (TrueType)", "segoesc.ttf");
fontsKey.SetValue("Segoe Script Bold (TrueType)", "segoescb.ttf");
}

using (RegistryKey fontSubstitutesKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", true))
{
fontSubstitutesKey.DeleteValue("Segoe UI", false);
}
}
catch (Exception ex)
{
ErrorLogger.LogError("FontHelper.RestoreDefaultGlobalFont", ex.Message, ex.StackTrace);
}
}
}
}
2 changes: 1 addition & 1 deletion Optimizer/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ internal static void LoadSettings()
else
{
// DEFAULT OPTIONS

CurrentOptions.Theme = Color.FromArgb(153, 102, 204);
CurrentOptions.AppsFolder = Path.Combine(KnownFolders.GetPath(KnownFolder.Downloads), Constants.DOWNLOADS_FOLDER);
Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
Expand Down
2 changes: 1 addition & 1 deletion Optimizer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static void Main(string[] switches)
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception error = (Exception)e.ExceptionObject;
ErrorLogger.LogError("[Program.Main-UnhandledException]", error.Message, error.StackTrace);
ErrorLogger.LogError("Program.Main-UnhandledException", error.Message, error.StackTrace);
}

private static void LoadSettings()
Expand Down
2 changes: 1 addition & 1 deletion Optimizer/SilentOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ internal static void ProcessTweaksWindows11()
if (CurrentSilentConfig.Tweaks.DisableVirtualizationBasedTechnology.Value)
{
MessageBox.Show("no vbs");
// OptimizeHelper.DisableVirtualizationBasedSecurity();
// OptimizeHelper.DisableVirtualizationBasedSecurity();
}
else
{
Expand Down
3 changes: 0 additions & 3 deletions Optimizer/UserFoldersHelper.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Optimizer
{
Expand Down

0 comments on commit 4d1520c

Please sign in to comment.