refactor: setup fonts based on operating system

This commit is contained in:
leo 2024-03-08 12:22:22 +08:00
parent 267c955c88
commit 2182d39e5f
6 changed files with 50 additions and 28 deletions

View file

@ -1,4 +1,6 @@
using System;
using Avalonia;
using Avalonia.Media;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
@ -11,6 +13,15 @@ namespace SourceGit.Native {
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)]
private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs);
public void SetupFonts(AppBuilder builder) {
builder.With(new FontManagerOptions() {
DefaultFamilyName = "Microsoft YaHei UI",
FontFallbacks = [
new FontFallback { FontFamily = new FontFamily("Microsoft YaHei UI") }
]
});
}
public string FindGitExecutable() {
var reg = Microsoft.Win32.RegistryKey.OpenBaseKey(
Microsoft.Win32.RegistryHive.LocalMachine,